]> jfr.im git - solanum.git/blobdiff - src/channel.c
ssld: use uint64_t explicitly when we want 64-bit counters
[solanum.git] / src / channel.c
index 92d36512596329a585684770b1644361dd76d966..5f3f56cc71ed7802d7c230ddb6d0e7b773cac8bb 100644 (file)
@@ -2,9 +2,9 @@
  *  ircd-ratbox: A slightly useful ircd.
  *  channel.c: Controls channels.
  *
- * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center 
- * Copyright (C) 1996-2002 Hybrid Development Team 
- * Copyright (C) 2002-2005 ircd-ratbox development team 
+ * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
+ * Copyright (C) 1996-2002 Hybrid Development Team
+ * Copyright (C) 2002-2005 ircd-ratbox development team
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -41,6 +41,8 @@
 #include "s_conf.h"            /* ConfigFileEntry, ConfigChannel */
 #include "s_newconf.h"
 #include "logger.h"
+#include "ipv4_from_ipv6.h"
+#include "s_assert.h"
 
 struct config_channel_entry ConfigChannel;
 rb_dlink_list global_channel_list;
@@ -49,16 +51,6 @@ static rb_bh *ban_heap;
 static rb_bh *topic_heap;
 static rb_bh *member_heap;
 
-static int channel_capabs[] = { CAP_EX, CAP_IE,
-       CAP_SERVICE,
-       CAP_TS6
-};
-
-#define NCHCAPS         (sizeof(channel_capabs)/sizeof(int))
-#define NCHCAP_COMBOS   (1 << NCHCAPS)
-
-static struct ChCapCombo chcap_combos[NCHCAP_COMBOS];
-
 static void free_topic(struct Channel *chptr);
 
 static int h_can_join;
@@ -105,12 +97,13 @@ free_channel(struct Channel *chptr)
 }
 
 struct Ban *
-allocate_ban(const char *banstr, const char *who)
+allocate_ban(const char *banstr, const char *who, const char *forward)
 {
        struct Ban *bptr;
        bptr = rb_bh_alloc(ban_heap);
        bptr->banstr = rb_strdup(banstr);
        bptr->who = rb_strdup(who);
+       bptr->forward = forward ? rb_strdup(forward) : NULL;
 
        return (bptr);
 }
@@ -120,6 +113,7 @@ free_ban(struct Ban *bptr)
 {
        rb_free(bptr->banstr);
        rb_free(bptr->who);
+       rb_free(bptr->forward);
        rb_bh_free(ban_heap, bptr);
 }
 
@@ -136,8 +130,19 @@ send_channel_join(struct Channel *chptr, struct Client *client_p)
        if (!IsClient(client_p))
                return;
 
-       sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
-                            client_p->name, client_p->username, client_p->host, chptr->chname);
+       sendto_channel_local_with_capability(ALL_MEMBERS, NOCAPS, CLICAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN %s",
+                                            client_p->name, client_p->username, client_p->host, chptr->chname);
+
+       sendto_channel_local_with_capability(ALL_MEMBERS, CLICAP_EXTENDED_JOIN, NOCAPS, chptr, ":%s!%s@%s JOIN %s %s :%s",
+                                            client_p->name, client_p->username, client_p->host, chptr->chname,
+                                            EmptyString(client_p->user->suser) ? "*" : client_p->user->suser,
+                                            client_p->info);
+
+       /* Send away message to away-notify enabled clients. */
+       if (client_p->user->away)
+               sendto_channel_local_with_capability_butone(client_p, ALL_MEMBERS, CLICAP_AWAY_NOTIFY, NOCAPS, chptr,
+                                                           ":%s!%s@%s AWAY :%s", client_p->name, client_p->username,
+                                                           client_p->host, client_p->user->away);
 }
 
 /* find_channel_membership()
@@ -213,7 +218,7 @@ find_channel_status(struct membership *msptr, int combine)
 /* add_user_to_channel()
  *
  * input       - channel to add client to, client to add, channel flags
- * output      - 
+ * output      -
  * side effects - user is added to channel
  */
 void
@@ -460,17 +465,34 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
                        if(IsInvisible(target_p) && !is_member)
                                continue;
 
-                       /* space, possible "@+" prefix */
-                       if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3)
+                       if (IsCapable(client_p, CLICAP_USERHOST_IN_NAMES))
                        {
-                               *(t - 1) = '\0';
-                               sendto_one(client_p, "%s", lbuf);
-                               cur_len = mlen;
-                               t = lbuf + mlen;
+                               /* space, possible "@+" prefix */
+                               if (cur_len + strlen(target_p->name) + strlen(target_p->username) + strlen(target_p->host) + 5 >= BUFSIZE - 5)
+                               {
+                                       *(t - 1) = '\0';
+                                       sendto_one(client_p, "%s", lbuf);
+                                       cur_len = mlen;
+                                       t = lbuf + mlen;
+                               }
+
+                               tlen = rb_sprintf(t, "%s%s!%s@%s ", find_channel_status(msptr, stack),
+                                                 target_p->name, target_p->username, target_p->host);
                        }
+                       else
+                       {
+                               /* space, possible "@+" prefix */
+                               if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3)
+                               {
+                                       *(t - 1) = '\0';
+                                       sendto_one(client_p, "%s", lbuf);
+                                       cur_len = mlen;
+                                       t = lbuf + mlen;
+                               }
 
-                       tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
-                                         target_p->name);
+                               tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
+                                                 target_p->name);
+                       }
 
                        cur_len += tlen;
                        t += tlen;
@@ -508,21 +530,26 @@ del_invite(struct Channel *chptr, struct Client *who)
        rb_dlinkFindDestroy(chptr, &who->user->invited);
 }
 
-/* is_banned()
+/* is_banned_list()
  *
- * input       - channel to check bans for, user to check bans against
- *                optional prebuilt buffers
+ * input       - channel to check bans for, ban list (banlist or quietlist),
+ *                user to check bans against, optional prebuilt buffers,
+ *                optional forward channel pointer
  * output      - 1 if banned, else 0
  * side effects -
  */
-int
-is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
-         const char *s, const char *s2)
+static int
+is_banned_list(struct Channel *chptr, rb_dlink_list *list,
+              struct Client *who, struct membership *msptr,
+              const char *s, const char *s2, const char **forward)
 {
        char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
        char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
        char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
+       char src_ip4host[NICKLEN + USERLEN + HOSTLEN + 6];
        char *s3 = NULL;
+       char *s4 = NULL;
+       struct sockaddr_in ip4;
        rb_dlink_node *ptr;
        struct Ban *actualBan = NULL;
        struct Ban *actualExcept = NULL;
@@ -555,15 +582,31 @@ is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
                        s3 = src_althost;
                }
        }
+#ifdef RB_IPV6
+       if(who->localClient->ip.ss_family == AF_INET6 &&
+                       ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4))
+       {
+               rb_sprintf(src_ip4host, "%s!%s@", who->name, who->username);
+               s4 = src_ip4host + strlen(src_ip4host);
+               rb_inet_ntop_sock((struct sockaddr *)&ip4,
+                               s4, src_ip4host + sizeof src_ip4host - s4);
+               s4 = src_ip4host;
+       }
+#endif
 
-       RB_DLINK_FOREACH(ptr, chptr->banlist.head)
+       RB_DLINK_FOREACH(ptr, list->head)
        {
                actualBan = ptr->data;
                if(match(actualBan->banstr, s) ||
                   match(actualBan->banstr, s2) ||
                   match_cidr(actualBan->banstr, s2) ||
                   match_extban(actualBan->banstr, who, chptr, CHFL_BAN) ||
-                  (s3 != NULL && match(actualBan->banstr, s3)))
+                  (s3 != NULL && match(actualBan->banstr, s3))
+#ifdef RB_IPV6
+                  ||
+                  (s4 != NULL && (match(actualBan->banstr, s4) || match_cidr(actualBan->banstr, s4)))
+#endif
+                  )
                        break;
                else
                        actualBan = NULL;
@@ -611,9 +654,27 @@ is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
                }
        }
 
+       if (actualBan && actualBan->forward && forward)
+               *forward = actualBan->forward;
+
        return ((actualBan ? CHFL_BAN : 0));
 }
 
+/* is_banned()
+ *
+ * input       - channel to check bans for, user to check bans against
+ *                optional prebuilt buffers, optional forward channel pointer
+ * output      - 1 if banned, else 0
+ * side effects -
+ */
+int
+is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
+         const char *s, const char *s2, const char **forward)
+{
+       return is_banned_list(chptr, &chptr->banlist, who, msptr, s, s2,
+                       forward);
+}
+
 /* is_quieted()
  *
  * input       - channel to check bans for, user to check bans against
@@ -625,110 +686,19 @@ int
 is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
           const char *s, const char *s2)
 {
-       char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
-       char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
-       char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
-       char *s3 = NULL;
-       rb_dlink_node *ptr;
-       struct Ban *actualBan = NULL;
-       struct Ban *actualExcept = NULL;
-
-       if(!MyClient(who))
-               return 0;
-
-       /* if the buffers havent been built, do it here */
-       if(s == NULL)
-       {
-               rb_sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
-               rb_sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
-
-               s = src_host;
-               s2 = src_iphost;
-       }
-       if(who->localClient->mangledhost != NULL)
-       {
-               /* if host mangling mode enabled, also check their real host */
-               if(!strcmp(who->host, who->localClient->mangledhost))
-               {
-                       rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
-                       s3 = src_althost;
-               }
-               /* if host mangling mode not enabled and no other spoof,
-                * also check the mangled form of their host */
-               else if (!IsDynSpoof(who))
-               {
-                       rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
-                       s3 = src_althost;
-               }
-       }
-
-       RB_DLINK_FOREACH(ptr, chptr->quietlist.head)
-       {
-               actualBan = ptr->data;
-               if(match(actualBan->banstr, s) ||
-                  match(actualBan->banstr, s2) ||
-                  match_cidr(actualBan->banstr, s2) ||
-                  match_extban(actualBan->banstr, who, chptr, CHFL_QUIET) ||
-                  (s3 != NULL && match(actualBan->banstr, s3)))
-                       break;
-               else
-                       actualBan = NULL;
-       }
-
-       if((actualBan != NULL) && ConfigChannel.use_except)
-       {
-               RB_DLINK_FOREACH(ptr, chptr->exceptlist.head)
-               {
-                       actualExcept = ptr->data;
-
-                       /* theyre exempted.. */
-                       if(match(actualExcept->banstr, s) ||
-                          match(actualExcept->banstr, s2) ||
-                          match_cidr(actualExcept->banstr, s2) ||
-                          match_extban(actualExcept->banstr, who, chptr, CHFL_EXCEPTION) ||
-                          (s3 != NULL && match(actualExcept->banstr, s3)))
-                       {
-                               /* cache the fact theyre not banned */
-                               if(msptr != NULL)
-                               {
-                                       msptr->bants = chptr->bants;
-                                       msptr->flags &= ~CHFL_BANNED;
-                               }
-
-                               return CHFL_EXCEPTION;
-                       }
-               }
-       }
-
-       /* cache the banned/not banned status */
-       if(msptr != NULL)
-       {
-               msptr->bants = chptr->bants;
-
-               if(actualBan != NULL)
-               {
-                       msptr->flags |= CHFL_BANNED;
-                       return CHFL_BAN;
-               }
-               else
-               {
-                       msptr->flags &= ~CHFL_BANNED;
-                       return 0;
-               }
-       }
-
-       return ((actualBan ? CHFL_BAN : 0));
+       return is_banned_list(chptr, &chptr->quietlist, who, msptr, s, s2,
+                       NULL);
 }
 
 /* can_join()
  *
  * input       - client to check, channel to check for, key
- * output      - reason for not being able to join, else 0
+ * output      - reason for not being able to join, else 0, channel name to forward to
  * side effects -
  * caveats      - this function should only be called on a local user.
  */
 int
-can_join(struct Client *source_p, struct Channel *chptr, char *key)
+can_join(struct Client *source_p, struct Channel *chptr, const char *key, const char **forward)
 {
        rb_dlink_node *invite = NULL;
        rb_dlink_node *ptr;
@@ -765,12 +735,22 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
                }
        }
 
-       if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN)
+       if((is_banned(chptr, source_p, NULL, src_host, src_iphost, forward)) == CHFL_BAN)
        {
                moduledata.approved = ERR_BANNEDFROMCHAN;
                goto finish_join_check;
        }
 
+       if(*chptr->mode.key && (EmptyString(key) || irccmp(chptr->mode.key, key)))
+       {
+               moduledata.approved = ERR_BADCHANNELKEY;
+               goto finish_join_check;
+       }
+
+       /* All checks from this point on will forward... */
+       if(forward)
+               *forward = chptr->mode.forward;
+
        if(chptr->mode.mode & MODE_INVITEONLY)
        {
                RB_DLINK_FOREACH(invite, source_p->user->invited.head)
@@ -797,9 +777,6 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
                }
        }
 
-       if(*chptr->mode.key && (EmptyString(key) || irccmp(chptr->mode.key, key)))
-               moduledata.approved = ERR_BADCHANNELKEY;
-
        if(chptr->mode.limit &&
           rb_dlink_list_length(&chptr->members) >= (unsigned long) chptr->mode.limit)
                i = ERR_CHANNELISFULL;
@@ -808,7 +785,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
        /* join throttling stuff --nenolod */
        else if(chptr->mode.join_num > 0 && chptr->mode.join_time > 0)
        {
-               if ((rb_current_time() - chptr->join_delta <= 
+               if ((rb_current_time() - chptr->join_delta <=
                        chptr->mode.join_time) && (chptr->join_count >=
                        chptr->mode.join_num))
                        i = ERR_THROTTLE;
@@ -844,6 +821,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
        hook_data_channel_approval moduledata;
 
        moduledata.approved = CAN_SEND_NONOP;
+       moduledata.dir = MODE_QUERY;
 
        if(IsServer(source_p) || IsService(source_p))
                return CAN_SEND_OPV;
@@ -882,7 +860,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
                        if(can_send_banned(msptr))
                                moduledata.approved = CAN_SEND_NO;
                }
-               else if(is_banned(chptr, source_p, msptr, NULL, NULL) == CHFL_BAN
+               else if(is_banned(chptr, source_p, msptr, NULL, NULL, NULL) == CHFL_BAN
                        || is_quieted(chptr, source_p, msptr, NULL, NULL) == CHFL_BAN)
                        moduledata.approved = CAN_SEND_NO;
        }
@@ -890,6 +868,12 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
        if(is_chanop_voiced(msptr))
                moduledata.approved = CAN_SEND_OPV;
 
+       moduledata.client = source_p;
+       moduledata.chptr = msptr->chptr;
+       moduledata.msptr = msptr;
+       moduledata.target = NULL;
+       moduledata.dir = (moduledata.approved == CAN_SEND_NO) ? MODE_ADD : MODE_QUERY;
+
        call_hook(h_can_send, &moduledata);
 
        return moduledata.approved;
@@ -899,7 +883,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
  * flood_attack_channel
  * inputs       - flag 0 if PRIVMSG 1 if NOTICE. RFC
  *                says NOTICE must not auto reply
- *              - pointer to source Client 
+ *              - pointer to source Client
  *             - pointer to target channel
  * output      - 1 if target is under flood attack
  * side effects        - check for flood attack on target chptr
@@ -982,7 +966,7 @@ find_bannickchange_channel(struct Client *client_p)
                        if (can_send_banned(msptr))
                                return chptr;
                }
-               else if (is_banned(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN
+               else if (is_banned(chptr, client_p, msptr, src_host, src_iphost, NULL) == CHFL_BAN
                        || is_quieted(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN)
                        return chptr;
        }
@@ -1107,7 +1091,7 @@ allocate_topic(struct Channel *chptr)
 
        /* Basically we allocate one large block for the topic and
         * the topic info.  We then split it up into two and shove it
-        * in the chptr 
+        * in the chptr
         */
        chptr->topic = ptr;
        chptr->topic_info = (char *) ptr + TOPICLEN + 1;
@@ -1214,7 +1198,8 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
                                           chptr->mode.join_time);
        }
 
-       if(*chptr->mode.forward && (ConfigChannel.use_forward || !IsClient(client_p)))
+       if(*chptr->mode.forward &&
+                       (ConfigChannel.use_forward || !IsClient(client_p)))
        {
                *mbuf++ = 'f';
 
@@ -1229,102 +1214,6 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
        return final;
 }
 
-/* Now lets do some stuff to keep track of what combinations of
- * servers exist...
- * Note that the number of combinations doubles each time you add
- * something to this list. Each one is only quick if no servers use that
- * combination, but if the numbers get too high here MODE will get too
- * slow. I suggest if you get more than 7 here, you consider getting rid
- * of some and merging or something. If it wasn't for irc+cs we would
- * probably not even need to bother about most of these, but unfortunately
- * we do. -A1kmm
- */
-
-/* void init_chcap_usage_counts(void)
- *
- * Inputs      - none
- * Output      - none
- * Side-effects        - Initialises the usage counts to zero. Fills in the
- *                chcap_yes and chcap_no combination tables.
- */
-void
-init_chcap_usage_counts(void)
-{
-       unsigned long m, c, y, n;
-
-       memset(chcap_combos, 0, sizeof(chcap_combos));
-
-       /* For every possible combination */
-       for (m = 0; m < NCHCAP_COMBOS; m++)
-       {
-               /* Check each capab */
-               for (c = y = n = 0; c < NCHCAPS; c++)
-               {
-                       if((m & (1 << c)) == 0)
-                               n |= channel_capabs[c];
-                       else
-                               y |= channel_capabs[c];
-               }
-               chcap_combos[m].cap_yes = y;
-               chcap_combos[m].cap_no = n;
-       }
-}
-
-/* void set_chcap_usage_counts(struct Client *serv_p)
- * Input: serv_p; The client whose capabs to register.
- * Output: none
- * Side-effects: Increments the usage counts for the correct capab
- *               combination.
- */
-void
-set_chcap_usage_counts(struct Client *serv_p)
-{
-       int n;
-
-       for (n = 0; n < NCHCAP_COMBOS; n++)
-       {
-               if(IsCapable(serv_p, chcap_combos[n].cap_yes) &&
-                  NotCapable(serv_p, chcap_combos[n].cap_no))
-               {
-                       chcap_combos[n].count++;
-                       return;
-               }
-       }
-
-       /* This should be impossible -A1kmm. */
-       s_assert(0);
-}
-
-/* void set_chcap_usage_counts(struct Client *serv_p)
- *
- * Inputs      - serv_p; The client whose capabs to register.
- * Output      - none
- * Side-effects        - Decrements the usage counts for the correct capab
- *                combination.
- */
-void
-unset_chcap_usage_counts(struct Client *serv_p)
-{
-       int n;
-
-       for (n = 0; n < NCHCAP_COMBOS; n++)
-       {
-               if(IsCapable(serv_p, chcap_combos[n].cap_yes) &&
-                  NotCapable(serv_p, chcap_combos[n].cap_no))
-               {
-                       /* Hopefully capabs can't change dynamically or anything... */
-                       s_assert(chcap_combos[n].count > 0);
-
-                       if(chcap_combos[n].count > 0)
-                               chcap_combos[n].count--;
-                       return;
-               }
-       }
-
-       /* This should be impossible -A1kmm. */
-       s_assert(0);
-}
-
 /* void send_cap_mode_changes(struct Client *client_p,
  *                        struct Client *source_p,
  *                        struct Channel *chptr, int cap, int nocap)
@@ -1336,6 +1225,9 @@ unset_chcap_usage_counts(struct Client *serv_p)
  * Reverted back to my original design, except that we now keep a count
  * of the number of servers which each combination as an optimisation, so
  * the capabs combinations which are not needed are not worked out. -A1kmm
+ *
+ * Removed most code here because we don't need to be compatible with ircd
+ * 2.8.21+CSr and stuff.  --nenolod
  */
 void
 send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
@@ -1347,108 +1239,94 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
        char *pbuf;
        const char *arg;
        int dir;
-       int j;
-       int cap;
-       int nocap;
        int arglen;
 
        /* Now send to servers... */
-       for (j = 0; j < NCHCAP_COMBOS; j++)
+       mc = 0;
+       nc = 0;
+       pbl = 0;
+       parabuf[0] = 0;
+       pbuf = parabuf;
+       dir = MODE_QUERY;
+
+       mbl = preflen = rb_sprintf(modebuf, ":%s TMODE %ld %s ",
+                                  use_id(source_p), (long) chptr->channelts,
+                                  chptr->chname);
+
+       /* loop the list of - modes we have */
+       for (i = 0; i < mode_count; i++)
        {
-               if(chcap_combos[j].count == 0)
+               /* if they dont support the cap we need, or they do support a cap they
+                * cant have, then dont add it to the modebuf.. that way they wont see
+                * the mode
+                */
+               if (mode_changes[i].letter == 0)
                        continue;
 
-               mc = 0;
-               nc = 0;
-               pbl = 0;
-               parabuf[0] = 0;
-               pbuf = parabuf;
-               dir = MODE_QUERY;
-
-               cap = chcap_combos[j].cap_yes;
-               nocap = chcap_combos[j].cap_no;
-
-               mbl = preflen = rb_sprintf(modebuf, ":%s TMODE %ld %s ",
-                                          use_id(source_p), (long) chptr->channelts,
-                                          chptr->chname);
+               if (!EmptyString(mode_changes[i].id))
+                       arg = mode_changes[i].id;
+               else
+                       arg = mode_changes[i].arg;
 
-               /* loop the list of - modes we have */
-               for (i = 0; i < mode_count; i++)
+               if(arg)
                {
-                       /* if they dont support the cap we need, or they do support a cap they
-                        * cant have, then dont add it to the modebuf.. that way they wont see
-                        * the mode
-                        */
-                       if((mode_changes[i].letter == 0) ||
-                          ((cap & mode_changes[i].caps) != mode_changes[i].caps)
-                          || ((nocap & mode_changes[i].nocaps) != mode_changes[i].nocaps))
-                               continue;
-
-                       if(!EmptyString(mode_changes[i].id))
-                               arg = mode_changes[i].id;
-                       else
-                               arg = mode_changes[i].arg;
+                       arglen = strlen(arg);
 
-                       if(arg)
-                       {
-                               arglen = strlen(arg);
-
-                               /* dont even think about it! --fl */
-                               if(arglen > MODEBUFLEN - 5)
-                                       continue;
-                       }
+                       /* dont even think about it! --fl */
+                       if(arglen > MODEBUFLEN - 5)
+                               continue;
+               }
 
-                       /* if we're creeping past the buf size, we need to send it and make
-                        * another line for the other modes
-                        * XXX - this could give away server topology with uids being
-                        * different lengths, but not much we can do, except possibly break
-                        * them as if they were the longest of the nick or uid at all times,
-                        * which even then won't work as we don't always know the uid -A1kmm.
-                        */
-                       if(arg && ((mc == MAXMODEPARAMSSERV) ||
-                                  ((mbl + pbl + arglen + 4) > (BUFSIZE - 3))))
-                       {
-                               if(nc != 0)
-                                       sendto_server(client_p, chptr, cap, nocap,
-                                                     "%s %s", modebuf, parabuf);
-                               nc = 0;
-                               mc = 0;
-
-                               mbl = preflen;
-                               pbl = 0;
-                               pbuf = parabuf;
-                               parabuf[0] = 0;
-                               dir = MODE_QUERY;
-                       }
+               /* if we're creeping past the buf size, we need to send it and make
+                * another line for the other modes
+                * XXX - this could give away server topology with uids being
+                * different lengths, but not much we can do, except possibly break
+                * them as if they were the longest of the nick or uid at all times,
+                * which even then won't work as we don't always know the uid -A1kmm.
+                */
+               if(arg && ((mc == MAXMODEPARAMSSERV) ||
+                          ((mbl + pbl + arglen + 4) > (BUFSIZE - 3))))
+               {
+                       if(nc != 0)
+                               sendto_server(client_p, chptr, NOCAPS, NOCAPS,
+                                             "%s %s", modebuf, parabuf);
+                       nc = 0;
+                       mc = 0;
+
+                       mbl = preflen;
+                       pbl = 0;
+                       pbuf = parabuf;
+                       parabuf[0] = 0;
+                       dir = MODE_QUERY;
+               }
 
-                       if(dir != mode_changes[i].dir)
-                       {
-                               modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
-                               dir = mode_changes[i].dir;
-                       }
+               if(dir != mode_changes[i].dir)
+               {
+                       modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
+                       dir = mode_changes[i].dir;
+               }
 
-                       modebuf[mbl++] = mode_changes[i].letter;
-                       modebuf[mbl] = 0;
-                       nc++;
+               modebuf[mbl++] = mode_changes[i].letter;
+               modebuf[mbl] = 0;
+               nc++;
 
-                       if(arg != NULL)
-                       {
-                               len = rb_sprintf(pbuf, "%s ", arg);
-                               pbuf += len;
-                               pbl += len;
-                               mc++;
-                       }
+               if(arg != NULL)
+               {
+                       len = rb_sprintf(pbuf, "%s ", arg);
+                       pbuf += len;
+                       pbl += len;
+                       mc++;
                }
+       }
 
-               if(pbl && parabuf[pbl - 1] == ' ')
-                       parabuf[pbl - 1] = 0;
+       if(pbl && parabuf[pbl - 1] == ' ')
+               parabuf[pbl - 1] = 0;
 
-               if(nc != 0)
-                       sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
-       }
+       if(nc != 0)
+               sendto_server(client_p, chptr, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
 }
 
-void 
+void
 resv_chan_forcepart(const char *name, const char *reason, int temp_time)
 {
        rb_dlink_node *ptr;
@@ -1486,7 +1364,7 @@ resv_chan_forcepart(const char *name, const char *reason, int temp_time)
                        /* notify opers & user they were removed from the channel */
                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                             "Forced PART for %s!%s@%s from %s (%s)",
-                                            target_p->name, target_p->username, 
+                                            target_p->name, target_p->username,
                                             target_p->host, name, reason);
 
                        if(temp_time > 0)