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 2939 by michael, Sun Jan 26 12:51:50 2014 UTC vs.
Revision 4800 by michael, Tue Oct 28 13:59:43 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 34 | Line 34
34   #include "irc_string.h"
35   #include "ircd.h"
36   #include "numeric.h"
37 < #include "s_serv.h"
38 < #include "s_user.h"
37 > #include "server.h"
38   #include "send.h"
39   #include "memory.h"
40   #include "mempool.h"
# Line 43 | Line 42
42  
43   /* 10 is a magic number in hybrid 6 NFI where it comes from -db */
44   #define BAN_FUDGE       10
46 – #define NCHCAPS         (sizeof(channel_capabs)/sizeof(int))
47 – #define NCHCAP_COMBOS   (1 << NCHCAPS)
48 –
45  
46   static char nuh_mask[MAXPARA][IRCD_BUFSIZE];
47   /* some buffers for rebuilding channel/nick lists with ,'s */
48   static char modebuf[IRCD_BUFSIZE];
49   static char parabuf[MODEBUFLEN];
50   static struct ChModeChange mode_changes[IRCD_BUFSIZE];
51 < static int mode_count;
52 < static int mode_limit;  /* number of modes set other than simple */
53 < static int simple_modes_mask;  /* bit mask of simple modes already set */
58 < #ifdef HALFOPS
59 < static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_TS6, CAP_HOPS };
60 < #else
61 < static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_TS6 };
62 < #endif
63 < static struct ChCapCombo chcap_combos[NCHCAP_COMBOS];
51 > static unsigned int mode_count;
52 > static unsigned int mode_limit;  /* number of modes set other than simple */
53 > static unsigned int simple_modes_mask;  /* bit mask of simple modes already set */
54   extern mp_pool_t *ban_pool;
55  
56 + const struct mode_letter chan_modes[] =
57 + {
58 +  { MODE_NOCTRL,     'c' },
59 +  { MODE_INVITEONLY, 'i' },
60 +  { MODE_MODERATED,  'm' },
61 +  { MODE_NOPRIVMSGS, 'n' },
62 +  { MODE_PRIVATE,    'p' },
63 +  { MODE_REGISTERED, 'r' },
64 +  { MODE_SECRET,     's' },
65 +  { MODE_TOPICLIMIT, 't' },
66 +  { MODE_MODREG,     'M' },
67 +  { MODE_OPERONLY,   'O' },
68 +  { MODE_REGONLY,    'R' },
69 +  { MODE_SSLONLY,    'S' },
70 +  { 0, '\0' }
71 + };
72 +
73  
74   /* check_string()
75   *
# Line 102 | Line 109 | check_string(char *s)
109   */
110  
111   int
112 < add_id(struct Client *client_p, struct Channel *chptr, char *banid, int type)
112 > add_id(struct Client *client_p, struct Channel *chptr, char *banid, unsigned int type)
113   {
114    dlink_list *list = NULL;
115 <  dlink_node *ban = NULL;
115 >  dlink_node *node = NULL;
116 >  struct Ban *banptr = NULL;
117    size_t len = 0;
118 <  struct Ban *ban_p = NULL;
119 <  unsigned int num_mask;
120 <  char name[NICKLEN + 1];
113 <  char user[USERLEN + 1];
114 <  char host[HOSTLEN + 1];
118 >  char name[NICKLEN + 1] = "";
119 >  char user[USERLEN + 1] = "";
120 >  char host[HOSTLEN + 1] = "";
121    struct split_nuh_item nuh;
122  
123 <  /* dont let local clients overflow the b/e/I lists */
123 >  /* Don't let local clients overflow the b/e/I lists */
124    if (MyClient(client_p))
125    {
126 <    num_mask = dlink_list_length(&chptr->banlist) +
127 <               dlink_list_length(&chptr->exceptlist) +
128 <               dlink_list_length(&chptr->invexlist);
126 >    unsigned int num_mask = dlink_list_length(&chptr->banlist) +
127 >                            dlink_list_length(&chptr->exceptlist) +
128 >                            dlink_list_length(&chptr->invexlist);
129  
130      if (num_mask >= ConfigChannel.max_bans)
131      {
132 <      sendto_one(client_p, form_str(ERR_BANLISTFULL),
127 <                 me.name, client_p->name, chptr->chname, banid);
132 >      sendto_one_numeric(client_p, &me, ERR_BANLISTFULL, chptr->name, banid);
133        return 0;
134      }
135  
# Line 166 | Line 171 | add_id(struct Client *client_p, struct C
171        return 0;
172    }
173  
174 <  DLINK_FOREACH(ban, list->head)
174 >  DLINK_FOREACH(node, list->head)
175    {
176 <    ban_p = ban->data;
176 >    banptr = node->data;
177  
178 <    if (!irccmp(ban_p->name, name) &&
179 <        !irccmp(ban_p->user, user) &&
180 <        !irccmp(ban_p->host, host))
178 >    if (!irccmp(banptr->name, name) &&
179 >        !irccmp(banptr->user, user) &&
180 >        !irccmp(banptr->host, host))
181        return 0;
182    }
183  
184 <  ban_p = mp_pool_get(ban_pool);
185 <  memset(ban_p, 0, sizeof(*ban_p));
186 <  ban_p->name = xstrdup(name);
187 <  ban_p->user = xstrdup(user);
188 <  ban_p->host = xstrdup(host);
189 <  ban_p->when = CurrentTime;
190 <  ban_p->len = len - 2;  /* -2 for @ and ! */
186 <  ban_p->type = parse_netmask(host, &ban_p->addr, &ban_p->bits);
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);
191  
192    if (IsClient(client_p))
193    {
194 <    ban_p->who = MyMalloc(strlen(client_p->name) +
195 <                          strlen(client_p->username) +
196 <                          strlen(client_p->host) + 3);
197 <    sprintf(ban_p->who, "%s!%s@%s", client_p->name,
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,
198              client_p->username, client_p->host);
199    }
200    else if (IsHidden(client_p) || (IsServer(client_p) && ConfigServerHide.hide_servers))
201 <    ban_p->who = xstrdup(me.name);
201 >    banptr->who = xstrdup(me.name);
202    else
203 <    ban_p->who = xstrdup(client_p->name);
203 >    banptr->who = xstrdup(client_p->name);
204  
205 <  dlinkAdd(ban_p, &ban_p->node, list);
205 >  dlinkAdd(banptr, &banptr->node, list);
206  
207    return 1;
208   }
# Line 211 | Line 215 | add_id(struct Client *client_p, struct C
215   * side effects -
216   */
217   static int
218 < del_id(struct Channel *chptr, char *banid, int type)
218 > del_id(struct Channel *chptr, char *banid, unsigned int type)
219   {
220 <  dlink_list *list;
221 <  dlink_node *ban;
222 <  struct Ban *banptr;
223 <  char name[NICKLEN + 1];
224 <  char user[USERLEN + 1];
221 <  char host[HOSTLEN + 1];
220 >  dlink_list *list = NULL;
221 >  dlink_node *node = NULL;
222 >  char name[NICKLEN + 1] = "";
223 >  char user[USERLEN + 1] = "";
224 >  char host[HOSTLEN + 1] = "";
225    struct split_nuh_item nuh;
226  
227    assert(banid);
# Line 258 | Line 261 | del_id(struct Channel *chptr, char *bani
261        return 0;
262    }
263  
264 <  DLINK_FOREACH(ban, list->head)
264 >  DLINK_FOREACH(node, list->head)
265    {
266 <    banptr = ban->data;
266 >    struct Ban *banptr = node->data;
267  
268      if (!irccmp(name, banptr->name) &&
269          !irccmp(user, banptr->user) &&
# Line 274 | Line 277 | del_id(struct Channel *chptr, char *bani
277    return 0;
278   }
279  
277 – const struct mode_letter chan_modes[] =
278 – {
279 –  { MODE_NOCTRL,     'c' },
280 –  { MODE_INVITEONLY, 'i' },
281 –  { MODE_MODERATED,  'm' },
282 –  { MODE_NOPRIVMSGS, 'n' },
283 –  { MODE_PRIVATE,    'p' },
284 –  { MODE_REGISTERED, 'r' },
285 –  { MODE_SECRET,     's' },
286 –  { MODE_TOPICLIMIT, 't' },
287 –  { MODE_MODREG,     'M' },
288 –  { MODE_OPERONLY,   'O' },
289 –  { MODE_REGONLY,    'R' },
290 –  { MODE_SSLONLY,    'S' },
291 –  { 0, '\0' }
292 – };
293 –
280   /* channel_modes()
281   *
282   * inputs       - pointer to channel
# Line 302 | Line 288 | const struct mode_letter chan_modes[] =
288   * chptr onto buffer mbuf with the parameters in pbuf.
289   */
290   void
291 < channel_modes(struct Channel *chptr, struct Client *client_p,
306 <              char *mbuf, char *pbuf)
291 > channel_modes(struct Channel *chptr, struct Client *client_p, char *mbuf, char *pbuf)
292   {
308 –  const struct mode_letter *tab = chan_modes;
309 –
293    *mbuf++ = '+';
294    *pbuf = '\0';
295  
296 <  for (; tab->mode; ++tab)
296 >  for (const struct mode_letter *tab = chan_modes; tab->mode; ++tab)
297      if (chptr->mode.mode & tab->mode)
298        *mbuf++ = tab->letter;
299  
# Line 346 | Line 329 | fix_key(char *arg)
329   {
330    unsigned char *s, *t, c;
331  
332 <  for (s = t = (unsigned char *)arg; (c = *s); s++)
332 >  for (s = t = (unsigned char *)arg; (c = *s); ++s)
333    {
334      c &= 0x7f;
335  
# Line 358 | Line 341 | fix_key(char *arg)
341    return arg;
342   }
343  
344 < /* fix_key_old()
345 < *
346 < * inputs       - pointer to key to clean up
347 < * output       - pointer to cleaned up key
365 < * side effects - input string is modifed
366 < *
367 < * Here we attempt to be compatible with older non-hybrid servers.
368 < * We can't back down from the ':' issue however.  --Rodder
369 < */
370 < static char *
371 < fix_key_old(char *arg)
372 < {
373 <  unsigned char *s, *t, c;
374 <
375 <  for (s = t = (unsigned char *)arg; (c = *s); s++)
376 <  {
377 <    c &= 0x7f;
378 <
379 <    if ((c != 0x0a) && (c != ':') &&
380 <        (c != 0x0d) && (c != ','))
381 <      *t++ = c;
382 <  }
383 <
384 <  *t = '\0';
385 <  return arg;
386 < }
387 <
388 < /* bitmasks for various error returns that set_channel_mode should only return
389 < * once per call  -orabidoo
390 < */
391 <
392 < #define SM_ERR_NOTS         0x00000001 /* No TS on channel  */
393 < #define SM_ERR_NOOPS        0x00000002 /* No chan ops       */
394 < #define SM_ERR_UNKNOWN      0x00000004
395 < #define SM_ERR_RPL_B        0x00000008
396 < #define SM_ERR_RPL_E        0x00000010
397 < #define SM_ERR_NOTONCHANNEL 0x00000020 /* Not on channel    */
398 < #define SM_ERR_RPL_I        0x00000040
399 < #define SM_ERR_NOTOPER      0x00000080
400 < #define SM_ERR_ONLYSERVER   0x00000100
401 <
402 < /* Now lets do some stuff to keep track of what combinations of
403 < * servers exist...
404 < * Note that the number of combinations doubles each time you add
405 < * something to this list. Each one is only quick if no servers use that
406 < * combination, but if the numbers get too high here MODE will get too
407 < * slow. I suggest if you get more than 7 here, you consider getting rid
408 < * of some and merging or something. If it wasn't for irc+cs we would
409 < * probably not even need to bother about most of these, but unfortunately
410 < * we do. -A1kmm
411 < */
412 <
413 < /* void init_chcap_usage_counts(void)
414 < *
415 < * Inputs       - none
416 < * Output       - none
417 < * Side-effects - Initialises the usage counts to zero. Fills in the
418 < *                chcap_yes and chcap_no combination tables.
344 > /*
345 > * inputs       - pointer to channel
346 > * output       - none
347 > * side effects - clear ban cache
348   */
349   void
350 < init_chcap_usage_counts(void)
350 > clear_ban_cache(struct Channel *chptr)
351   {
352 <  unsigned long m, c, y, n;
424 <
425 <  memset(chcap_combos, 0, sizeof(chcap_combos));
352 >  dlink_node *node = NULL;
353  
354 <  /* For every possible combination */
428 <  for (m = 0; m < NCHCAP_COMBOS; m++)
354 >  DLINK_FOREACH(node, chptr->locmembers.head)
355    {
356 <    /* Check each capab */
357 <    for (c = y = n = 0; c < NCHCAPS; c++)
432 <    {
433 <      if ((m & (1 << c)) == 0)
434 <        n |= channel_capabs[c];
435 <      else
436 <        y |= channel_capabs[c];
437 <    }
438 <
439 <    chcap_combos[m].cap_yes = y;
440 <    chcap_combos[m].cap_no  = n;
356 >    struct Membership *ms = node->data;
357 >    ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
358    }
359   }
360  
444 – /* void set_chcap_usage_counts(struct Client *serv_p)
445 – * Input: serv_p; The client whose capabs to register.
446 – * Output: none
447 – * Side-effects: Increments the usage counts for the correct capab
448 – *               combination.
449 – */
361   void
362 < set_chcap_usage_counts(struct Client *serv_p)
362 > clear_ban_cache_client(struct Client *client_p)
363   {
364 <  int n;
364 >  dlink_node *node = NULL;
365  
366 <  for (n = 0; n < NCHCAP_COMBOS; n++)
366 >  DLINK_FOREACH(node, client_p->channel.head)
367    {
368 <    if (((serv_p->localClient->caps & chcap_combos[n].cap_yes) ==
369 <         chcap_combos[n].cap_yes) &&
459 <        ((serv_p->localClient->caps & chcap_combos[n].cap_no) == 0))
460 <    {
461 <      chcap_combos[n].count++;
462 <      return;
463 <    }
368 >    struct Membership *ms = node->data;
369 >    ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
370    }
465 –
466 –  /* This should be impossible -A1kmm. */
467 –  assert(0);
371   }
372  
373 < /* void set_chcap_usage_counts(struct Client *serv_p)
374 < *
375 < * Inputs       - serv_p; The client whose capabs to register.
473 < * Output       - none
474 < * Side-effects - Decrements the usage counts for the correct capab
475 < *                combination.
373 > /*
374 > * Bitmasks for various error returns that set_channel_mode should only return
375 > * once per call  -orabidoo
376   */
377 < void
478 < unset_chcap_usage_counts(struct Client *serv_p)
377 > enum
378   {
379 <  int n;
380 <
381 <  for (n = 0; n < NCHCAP_COMBOS; n++)
382 <  {
383 <    if ((serv_p->localClient->caps & chcap_combos[n].cap_yes) ==
384 <        chcap_combos[n].cap_yes &&
385 <        (serv_p->localClient->caps & chcap_combos[n].cap_no) == 0)
386 <    {
387 <      /* Hopefully capabs can't change dynamically or anything... */
489 <      assert(chcap_combos[n].count > 0);
490 <      chcap_combos[n].count--;
491 <      return;
492 <    }
493 <  }
494 <
495 <  /* This should be impossible -A1kmm. */
496 <  assert(0);
497 < }
379 >  SM_ERR_NOOPS        = 1 << 0,  /* No chan ops */
380 >  SM_ERR_UNKNOWN      = 1 << 1,
381 >  SM_ERR_RPL_B        = 1 << 2,
382 >  SM_ERR_RPL_E        = 1 << 3,
383 >  SM_ERR_RPL_I        = 1 << 4,
384 >  SM_ERR_NOTONCHANNEL = 1 << 5,  /* Client is not on channel */
385 >  SM_ERR_NOTOPER      = 1 << 6,
386 >  SM_ERR_ONLYSERVER   = 1 << 7
387 > };
388  
389   /* Mode functions handle mode changes for a particular mode... */
390   static void
391 < chm_nosuch(struct Client *client_p, struct Client *source_p,
502 <           struct Channel *chptr, int parc, int *parn,
391 > chm_nosuch(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
392             char **parv, int *errors, int alev, int dir, char c, unsigned int d)
393   {
394    if (*errors & SM_ERR_UNKNOWN)
395      return;
396  
397    *errors |= SM_ERR_UNKNOWN;
398 <  sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name,
510 <             source_p->name, c);
398 >  sendto_one_numeric(source_p, &me, ERR_UNKNOWNMODE, c);
399   }
400  
401   static void
402 < chm_simple(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
403 <           int parc, int *parn, char **parv, int *errors, int alev, int dir,
516 <           char c, unsigned int d)
402 > chm_simple(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
403 >           char **parv, int *errors, int alev, int dir, char c, unsigned int d)
404   {
405 <  if ((alev < CHACCESS_HALFOP) ||
519 <      ((d == MODE_PRIVATE) && (alev < CHACCESS_CHANOP)))
405 >  if (alev < CHACCESS_HALFOP)
406    {
407      if (!(*errors & SM_ERR_NOOPS))
408 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
409 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
410 <                 me.name, source_p->name, chptr->chname);
408 >      sendto_one_numeric(source_p, &me,
409 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
410 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
411      *errors |= SM_ERR_NOOPS;
412      return;
413    }
# Line 545 | Line 431 | chm_simple(struct Client *client_p, stru
431      chptr->mode.mode |= d;
432  
433      mode_changes[mode_count].letter = c;
434 <    mode_changes[mode_count].dir = MODE_ADD;
549 <    mode_changes[mode_count].caps = 0;
550 <    mode_changes[mode_count].nocaps = 0;
434 >    mode_changes[mode_count].arg = NULL;
435      mode_changes[mode_count].id = NULL;
436 <    mode_changes[mode_count].mems = ALL_MEMBERS;
553 <    mode_changes[mode_count++].arg = NULL;
436 >    mode_changes[mode_count++].dir = dir;
437    }
438    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
439    {
# Line 559 | Line 442 | chm_simple(struct Client *client_p, stru
442      chptr->mode.mode &= ~d;
443  
444      mode_changes[mode_count].letter = c;
445 <    mode_changes[mode_count].dir = MODE_DEL;
563 <    mode_changes[mode_count].caps = 0;
564 <    mode_changes[mode_count].nocaps = 0;
565 <    mode_changes[mode_count].mems = ALL_MEMBERS;
445 >    mode_changes[mode_count].arg = NULL;
446      mode_changes[mode_count].id = NULL;
447 <    mode_changes[mode_count++].arg = NULL;
447 >    mode_changes[mode_count++].dir = dir;
448    }
449   }
450  
451   static void
452 < chm_registered(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
453 <           int parc, int *parn, char **parv, int *errors, int alev, int dir,
574 <           char c, unsigned int d)
452 > chm_registered(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
453 >               char **parv, int *errors, int alev, int dir, char c, unsigned int d)
454   {
455    if (!IsServer(source_p) && !HasFlag(source_p, FLAGS_SERVICE))
456    {
457      if (!(*errors & SM_ERR_ONLYSERVER))
458 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
459 <                                    ERR_NOTONCHANNEL : ERR_ONLYSERVERSCANCHANGE),
460 <                 me.name, source_p->name, chptr->chname);
458 >      sendto_one_numeric(source_p, &me,
459 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
460 >                         ERR_ONLYSERVERSCANCHANGE, chptr->name);
461      *errors |= SM_ERR_ONLYSERVER;
462      return;
463    }
# Line 602 | Line 481 | chm_registered(struct Client *client_p,
481      chptr->mode.mode |= d;
482  
483      mode_changes[mode_count].letter = c;
484 <    mode_changes[mode_count].dir = MODE_ADD;
606 <    mode_changes[mode_count].caps = 0;
607 <    mode_changes[mode_count].nocaps = 0;
484 >    mode_changes[mode_count].arg = NULL;
485      mode_changes[mode_count].id = NULL;
486 <    mode_changes[mode_count].mems = ALL_MEMBERS;
610 <    mode_changes[mode_count++].arg = NULL;
486 >    mode_changes[mode_count++].dir = dir;
487    }
488    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
489    {
# Line 616 | Line 492 | chm_registered(struct Client *client_p,
492      chptr->mode.mode &= ~d;
493  
494      mode_changes[mode_count].letter = c;
495 <    mode_changes[mode_count].dir = MODE_DEL;
620 <    mode_changes[mode_count].caps = 0;
621 <    mode_changes[mode_count].nocaps = 0;
622 <    mode_changes[mode_count].mems = ALL_MEMBERS;
495 >    mode_changes[mode_count].arg = NULL;
496      mode_changes[mode_count].id = NULL;
497 <    mode_changes[mode_count++].arg = NULL;
497 >    mode_changes[mode_count++].dir = dir;
498    }
499   }
500  
501   static void
502 < chm_operonly(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
503 <            int parc, int *parn, char **parv, int *errors, int alev, int dir,
631 <            char c, unsigned int d)
502 > chm_operonly(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
503 >             char **parv, int *errors, int alev, int dir, char c, unsigned int d)
504   {
505 <  if ((alev < CHACCESS_HALFOP) ||
634 <      ((d == MODE_PRIVATE) && (alev < CHACCESS_CHANOP)))
505 >  if (alev < CHACCESS_CHANOP)
506    {
507      if (!(*errors & SM_ERR_NOOPS))
508 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
509 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
510 <                 me.name, source_p->name, chptr->chname);
508 >      sendto_one_numeric(source_p, &me,
509 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
510 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
511 >
512      *errors |= SM_ERR_NOOPS;
513      return;
514    }
515 <  else if (MyClient(source_p) && !HasUMode(source_p, UMODE_OPER))
515 >
516 >  if (MyClient(source_p) && !HasUMode(source_p, UMODE_OPER))
517    {
518      if (!(*errors & SM_ERR_NOTOPER))
519 <    {
647 <      if (alev == CHACCESS_NOTONCHAN)
648 <        sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
649 <                   me.name, source_p->name, chptr->chname);
650 <      else
651 <        sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
652 <                   me.name, source_p->name);
653 <    }
519 >      sendto_one_numeric(source_p, &me, ERR_NOPRIVILEGES);
520  
521      *errors |= SM_ERR_NOTOPER;
522      return;
# Line 667 | Line 533 | chm_operonly(struct Client *client_p, st
533      chptr->mode.mode |= d;
534  
535      mode_changes[mode_count].letter = c;
536 <    mode_changes[mode_count].dir = MODE_ADD;
671 <    mode_changes[mode_count].caps = 0;
672 <    mode_changes[mode_count].nocaps = 0;
536 >    mode_changes[mode_count].arg = NULL;
537      mode_changes[mode_count].id = NULL;
538 <    mode_changes[mode_count].mems = ALL_MEMBERS;
675 <    mode_changes[mode_count].mems = ALL_MEMBERS;
676 <    mode_changes[mode_count++].arg = NULL;
538 >    mode_changes[mode_count++].dir = dir;
539    }
540    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
541    {
# Line 682 | Line 544 | chm_operonly(struct Client *client_p, st
544      chptr->mode.mode &= ~d;
545  
546      mode_changes[mode_count].letter = c;
547 <    mode_changes[mode_count].dir = MODE_DEL;
686 <    mode_changes[mode_count].caps = 0;
687 <    mode_changes[mode_count].nocaps = 0;
688 <    mode_changes[mode_count].mems = ALL_MEMBERS;
547 >    mode_changes[mode_count].arg = NULL;
548      mode_changes[mode_count].id = NULL;
549 <    mode_changes[mode_count++].arg = NULL;
549 >    mode_changes[mode_count++].dir = dir;
550    }
551   }
552  
553   static void
554 < chm_ban(struct Client *client_p, struct Client *source_p,
696 <        struct Channel *chptr, int parc, int *parn,
554 > chm_ban(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
555          char **parv, int *errors, int alev, int dir, char c, unsigned int d)
556   {
557    char *mask = NULL;
558  
559    if (dir == MODE_QUERY || parc <= *parn)
560    {
561 <    dlink_node *ptr = NULL;
561 >    dlink_node *node = NULL;
562  
563      if (*errors & SM_ERR_RPL_B)
564        return;
565  
566      *errors |= SM_ERR_RPL_B;
567  
568 <    DLINK_FOREACH(ptr, chptr->banlist.head)
568 >    DLINK_FOREACH(node, chptr->banlist.head)
569      {
570 <      const struct Ban *banptr = ptr->data;
571 <      sendto_one(client_p, form_str(RPL_BANLIST),
572 <                 me.name, client_p->name, chptr->chname,
573 <                 banptr->name, banptr->user, banptr->host,
716 <                 banptr->who, banptr->when);
570 >      const struct Ban *banptr = node->data;
571 >      sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->name,
572 >                         banptr->name, banptr->user, banptr->host,
573 >                         banptr->who, banptr->when);
574      }
575  
576 <    sendto_one(source_p, form_str(RPL_ENDOFBANLIST), me.name,
720 <               source_p->name, chptr->chname);
576 >    sendto_one_numeric(source_p, &me, RPL_ENDOFBANLIST, chptr->name);
577      return;
578    }
579  
580    if (alev < CHACCESS_HALFOP)
581    {
582      if (!(*errors & SM_ERR_NOOPS))
583 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
584 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
585 <                 me.name, source_p->name, chptr->chname);
583 >      sendto_one_numeric(source_p, &me,
584 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
585 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
586      *errors |= SM_ERR_NOOPS;
587      return;
588    }
# Line 736 | Line 592 | chm_ban(struct Client *client_p, struct
592  
593    mask = nuh_mask[*parn];
594    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
595 <  ++*parn;
595 >  ++(*parn);
596  
597 <  if (IsServer(client_p))
597 >  if (!MyConnect(source_p))
598      if (strchr(mask, ' '))
599        return;
600  
# Line 757 | Line 613 | chm_ban(struct Client *client_p, struct
613    }
614  
615    mode_changes[mode_count].letter = c;
616 <  mode_changes[mode_count].dir = dir;
761 <  mode_changes[mode_count].caps = 0;
762 <  mode_changes[mode_count].nocaps = 0;
763 <  mode_changes[mode_count].mems = ALL_MEMBERS;
616 >  mode_changes[mode_count].arg = mask;
617    mode_changes[mode_count].id = NULL;
618 <  mode_changes[mode_count++].arg = mask;
618 >  mode_changes[mode_count++].dir = dir;
619   }
620  
621   static void
622 < chm_except(struct Client *client_p, struct Client *source_p,
770 <           struct Channel *chptr, int parc, int *parn,
622 > chm_except(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
623             char **parv, int *errors, int alev, int dir, char c, unsigned int d)
624   {
625    char *mask = NULL;
626  
775 –  if (alev < CHACCESS_HALFOP)
776 –  {
777 –    if (!(*errors & SM_ERR_NOOPS))
778 –      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
779 –                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
780 –                 me.name, source_p->name, chptr->chname);
781 –    *errors |= SM_ERR_NOOPS;
782 –    return;
783 –  }
784 –
627    if (dir == MODE_QUERY || parc <= *parn)
628    {
629 <    dlink_node *ptr = NULL;
629 >    dlink_node *node = NULL;
630  
631      if (*errors & SM_ERR_RPL_E)
632        return;
633  
634      *errors |= SM_ERR_RPL_E;
635  
636 <    DLINK_FOREACH(ptr, chptr->exceptlist.head)
636 >    DLINK_FOREACH(node, chptr->exceptlist.head)
637      {
638 <      const struct Ban *banptr = ptr->data;
639 <      sendto_one(client_p, form_str(RPL_EXCEPTLIST),
640 <                 me.name, client_p->name, chptr->chname,
641 <                 banptr->name, banptr->user, banptr->host,
642 <                 banptr->who, banptr->when);
638 >      const struct Ban *banptr = node->data;
639 >
640 >      sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->name,
641 >                         banptr->name, banptr->user, banptr->host,
642 >                         banptr->who, banptr->when);
643      }
644  
645 <    sendto_one(source_p, form_str(RPL_ENDOFEXCEPTLIST), me.name,
646 <               source_p->name, chptr->chname);
645 >    sendto_one_numeric(source_p, &me, RPL_ENDOFEXCEPTLIST, chptr->name);
646 >    return;
647 >  }
648 >
649 >  if (alev < CHACCESS_HALFOP)
650 >  {
651 >    if (!(*errors & SM_ERR_NOOPS))
652 >      sendto_one_numeric(source_p, &me,
653 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
654 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
655 >    *errors |= SM_ERR_NOOPS;
656      return;
657    }
658  
# Line 810 | Line 661 | chm_except(struct Client *client_p, stru
661  
662    mask = nuh_mask[*parn];
663    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
664 <  ++*parn;
664 >  ++(*parn);
665  
666 <  if (IsServer(client_p))
666 >  if (!MyConnect(source_p))
667      if (strchr(mask, ' '))
668        return;
669  
# Line 831 | Line 682 | chm_except(struct Client *client_p, stru
682    }
683  
684    mode_changes[mode_count].letter = c;
685 <  mode_changes[mode_count].dir = dir;
835 <  mode_changes[mode_count].caps = 0;
836 <  mode_changes[mode_count].nocaps = 0;
837 <  mode_changes[mode_count].mems = ONLY_CHANOPS;
685 >  mode_changes[mode_count].arg = mask;
686    mode_changes[mode_count].id = NULL;
687 <  mode_changes[mode_count++].arg = mask;
687 >  mode_changes[mode_count++].dir = dir;
688   }
689  
690   static void
691 < chm_invex(struct Client *client_p, struct Client *source_p,
844 <          struct Channel *chptr, int parc, int *parn,
691 > chm_invex(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
692            char **parv, int *errors, int alev, int dir, char c, unsigned int d)
693   {
694    char *mask = NULL;
695  
849 –  if (alev < CHACCESS_HALFOP)
850 –  {
851 –    if (!(*errors & SM_ERR_NOOPS))
852 –      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
853 –                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
854 –                 me.name, source_p->name, chptr->chname);
855 –    *errors |= SM_ERR_NOOPS;
856 –    return;
857 –  }
858 –
696    if (dir == MODE_QUERY || parc <= *parn)
697    {
698 <    dlink_node *ptr = NULL;
698 >    dlink_node *node = NULL;
699  
700      if (*errors & SM_ERR_RPL_I)
701        return;
702  
703      *errors |= SM_ERR_RPL_I;
704  
705 <    DLINK_FOREACH(ptr, chptr->invexlist.head)
705 >    DLINK_FOREACH(node, chptr->invexlist.head)
706      {
707 <      const struct Ban *banptr = ptr->data;
708 <      sendto_one(client_p, form_str(RPL_INVITELIST), me.name,
709 <                 client_p->name, chptr->chname,
710 <                 banptr->name, banptr->user, banptr->host,
711 <                 banptr->who, banptr->when);
707 >      const struct Ban *banptr = node->data;
708 >
709 >      sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->name,
710 >                         banptr->name, banptr->user, banptr->host,
711 >                         banptr->who, banptr->when);
712      }
713  
714 <    sendto_one(source_p, form_str(RPL_ENDOFINVITELIST), me.name,
715 <               source_p->name, chptr->chname);
714 >    sendto_one_numeric(source_p, &me, RPL_ENDOFINVEXLIST, chptr->name);
715 >    return;
716 >  }
717 >
718 >  if (alev < CHACCESS_HALFOP)
719 >  {
720 >    if (!(*errors & SM_ERR_NOOPS))
721 >      sendto_one_numeric(source_p, &me,
722 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
723 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
724 >    *errors |= SM_ERR_NOOPS;
725      return;
726    }
727  
# Line 884 | Line 730 | chm_invex(struct Client *client_p, struc
730  
731    mask = nuh_mask[*parn];
732    memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn]));
733 <  ++*parn;
733 >  ++(*parn);
734  
735 <  if (IsServer(client_p))
735 >  if (!MyConnect(source_p))
736      if (strchr(mask, ' '))
737        return;
738  
# Line 905 | Line 751 | chm_invex(struct Client *client_p, struc
751    }
752  
753    mode_changes[mode_count].letter = c;
754 <  mode_changes[mode_count].dir = dir;
909 <  mode_changes[mode_count].caps = 0;
910 <  mode_changes[mode_count].nocaps = 0;
911 <  mode_changes[mode_count].mems = ONLY_CHANOPS;
754 >  mode_changes[mode_count].arg = mask;
755    mode_changes[mode_count].id = NULL;
756 <  mode_changes[mode_count++].arg = mask;
914 < }
915 <
916 < /*
917 < * inputs       - pointer to channel
918 < * output       - none
919 < * side effects - clear ban cache
920 < */
921 < void
922 < clear_ban_cache(struct Channel *chptr)
923 < {
924 <  dlink_node *ptr = NULL;
925 <
926 <  DLINK_FOREACH(ptr, chptr->members.head)
927 <  {
928 <    struct Membership *ms = ptr->data;
929 <
930 <    if (MyConnect(ms->client_p))
931 <      ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
932 <  }
933 < }
934 <
935 < void
936 < clear_ban_cache_client(struct Client *client_p)
937 < {
938 <  dlink_node *ptr = NULL;
939 <
940 <  DLINK_FOREACH(ptr, client_p->channel.head)
941 <  {
942 <    struct Membership *ms = ptr->data;
943 <    ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED);
944 <  }
756 >  mode_changes[mode_count++].dir = dir;
757   }
758  
759   static void
760 < chm_op(struct Client *client_p, struct Client *source_p,
761 <       struct Channel *chptr, int parc, int *parn,
950 <       char **parv, int *errors, int alev, int dir, char c, unsigned int d)
760 > chm_voice(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
761 >          char **parv, int *errors, int alev, int dir, char c, unsigned int d)
762   {
763 <  const char *opnick = NULL;
953 <  struct Client *targ_p;
763 >  struct Client *target_p;
764    struct Membership *member;
955 –  int caps = 0;
765  
766 <  if (alev < CHACCESS_CHANOP)
766 >  if (alev < CHACCESS_HALFOP)
767    {
768      if (!(*errors & SM_ERR_NOOPS))
769 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
770 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
771 <                 me.name, source_p->name, chptr->chname);
769 >      sendto_one_numeric(source_p, &me,
770 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
771 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
772      *errors |= SM_ERR_NOOPS;
773      return;
774    }
775  
776 <  if ((dir == MODE_QUERY) || (parc <= *parn))
776 >  if (dir == MODE_QUERY || parc <= *parn)
777      return;
778  
779 <  opnick = parv[(*parn)++];
779 >  if ((target_p = find_chasing(source_p, parv[(*parn)++])) == NULL)
780 >    return;  /* find_chasing sends ERR_NOSUCHNICK */
781  
782 <  if ((targ_p = find_chasing(source_p, opnick, NULL)) == NULL)
973 <    return;
974 <  if (!IsClient(targ_p))
975 <    return;
976 <
977 <  if ((member = find_channel_link(targ_p, chptr)) == NULL)
782 >  if ((member = find_channel_link(target_p, chptr)) == NULL)
783    {
784      if (!(*errors & SM_ERR_NOTONCHANNEL))
785 <      sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL), me.name,
981 <                 source_p->name, opnick, chptr->chname);
785 >      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
786      *errors |= SM_ERR_NOTONCHANNEL;
787      return;
788    }
# Line 987 | Line 791 | chm_op(struct Client *client_p, struct C
791      return;
792  
793    /* no redundant mode changes */
794 <  if (dir == MODE_ADD &&  has_member_flags(member, CHFL_CHANOP))
794 >  if (dir == MODE_ADD &&  has_member_flags(member, CHFL_VOICE))
795      return;
796 <  if (dir == MODE_DEL && !has_member_flags(member, CHFL_CHANOP))
993 <  {
994 < #ifdef HALFOPS
995 <    if (has_member_flags(member, CHFL_HALFOP))
996 <    {
997 <      --*parn;
998 <      chm_hop(client_p, source_p, chptr, parc, parn, parv, errors, alev,
999 <              dir, c, d);
1000 <    }
1001 < #endif
796 >  if (dir == MODE_DEL && !has_member_flags(member, CHFL_VOICE))
797      return;
1003 –  }
798  
799 < #ifdef HALFOPS
800 <  if (dir == MODE_ADD && has_member_flags(member, CHFL_HALFOP))
801 <  {
802 <    /* promoting from % to @ is visible only to CAP_HOPS servers */
1009 <    mode_changes[mode_count].letter = 'h';
1010 <    mode_changes[mode_count].dir = MODE_DEL;
1011 <    mode_changes[mode_count].caps = caps = CAP_HOPS;
1012 <    mode_changes[mode_count].nocaps = 0;
1013 <    mode_changes[mode_count].mems = ALL_MEMBERS;
1014 <    mode_changes[mode_count].id = NULL;
1015 <    mode_changes[mode_count].arg = targ_p->name;
1016 <    mode_changes[mode_count++].client = targ_p;
1017 <  }
1018 < #endif
1019 <
1020 <  mode_changes[mode_count].letter = 'o';
1021 <  mode_changes[mode_count].dir = dir;
1022 <  mode_changes[mode_count].caps = caps;
1023 <  mode_changes[mode_count].nocaps = 0;
1024 <  mode_changes[mode_count].mems = ALL_MEMBERS;
1025 <  mode_changes[mode_count].id = targ_p->id;
1026 <  mode_changes[mode_count].arg = targ_p->name;
1027 <  mode_changes[mode_count++].client = targ_p;
799 >  mode_changes[mode_count].letter = c;
800 >  mode_changes[mode_count].arg = target_p->name;
801 >  mode_changes[mode_count].id = target_p->id;
802 >  mode_changes[mode_count++].dir = dir;
803  
804    if (dir == MODE_ADD)
805 <  {
1031 <    AddMemberFlag(member, CHFL_CHANOP);
1032 <    DelMemberFlag(member, CHFL_DEOPPED | CHFL_HALFOP);
1033 <  }
805 >    AddMemberFlag(member, CHFL_VOICE);
806    else
807 <    DelMemberFlag(member, CHFL_CHANOP);
807 >    DelMemberFlag(member, CHFL_VOICE);
808   }
809  
1038 – #ifdef HALFOPS
810   static void
811 < chm_hop(struct Client *client_p, struct Client *source_p,
812 <       struct Channel *chptr, int parc, int *parn,
1042 <       char **parv, int *errors, int alev, int dir, char c, unsigned int d)
811 > chm_hop(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
812 >        char **parv, int *errors, int alev, int dir, char c, unsigned int d)
813   {
814 <  const char *opnick = NULL;
1045 <  struct Client *targ_p;
814 >  struct Client *target_p;
815    struct Membership *member;
816  
817 <  /* *sigh* - dont allow halfops to set +/-h, they could fully control a
1049 <   * channel if there were no ops - it doesnt solve anything.. MODE_PRIVATE
1050 <   * when used with MODE_SECRET is paranoid - cant use +p
1051 <   *
1052 <   * it needs to be optional per channel - but not via +p, that or remove
1053 <   * paranoid.. -- fl_
1054 <   *
1055 <   * +p means paranoid, it is useless for anything else on modern IRC, as
1056 <   * list isn't really usable. If you want to have a private channel these
1057 <   * days, you set it +s. Halfops can no longer remove simple modes when
1058 <   * +p is set (although they can set +p) so it is safe to use this to
1059 <   * control whether they can (de)halfop...
1060 <   */
1061 <  if (alev <
1062 <      ((chptr->mode.mode & MODE_PRIVATE) ? CHACCESS_CHANOP : CHACCESS_HALFOP))
817 >  if (alev < CHACCESS_CHANOP)
818    {
819      if (!(*errors & SM_ERR_NOOPS))
820 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
821 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
822 <                 me.name, source_p->name, chptr->chname);
820 >      sendto_one_numeric(source_p, &me,
821 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
822 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
823      *errors |= SM_ERR_NOOPS;
824      return;
825    }
826  
827 <  if ((dir == MODE_QUERY) || (parc <= *parn))
827 >  if (dir == MODE_QUERY || parc <= *parn)
828      return;
829  
830 <  opnick = parv[(*parn)++];
830 >  if ((target_p = find_chasing(source_p, parv[(*parn)++])) == NULL)
831 >    return;  /* find_chasing sends ERR_NOSUCHNICK */
832  
833 <  if ((targ_p = find_chasing(source_p, opnick, NULL)) == NULL)
1078 <    return;
1079 <  if (!IsClient(targ_p))
1080 <    return;
1081 <
1082 <  if ((member = find_channel_link(targ_p, chptr)) == NULL)
833 >  if ((member = find_channel_link(target_p, chptr)) == NULL)
834    {
835      if (!(*errors & SM_ERR_NOTONCHANNEL))
836 <      sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
1086 <                 me.name, source_p->name, opnick, chptr->chname);
836 >      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
837      *errors |= SM_ERR_NOTONCHANNEL;
838      return;
839    }
# Line 1092 | Line 842 | chm_hop(struct Client *client_p, struct
842      return;
843  
844    /* no redundant mode changes */
845 <  if (dir == MODE_ADD &&  has_member_flags(member, CHFL_HALFOP | CHFL_CHANOP))
845 >  if (dir == MODE_ADD &&  has_member_flags(member, CHFL_HALFOP))
846      return;
847    if (dir == MODE_DEL && !has_member_flags(member, CHFL_HALFOP))
848      return;
849  
850 <  mode_changes[mode_count].letter = 'h';
851 <  mode_changes[mode_count].dir = dir;
852 <  mode_changes[mode_count].caps = CAP_HOPS;
853 <  mode_changes[mode_count].nocaps = 0;
1104 <  mode_changes[mode_count].mems = ALL_MEMBERS;
1105 <  mode_changes[mode_count].id = targ_p->id;
1106 <  mode_changes[mode_count].arg = targ_p->name;
1107 <  mode_changes[mode_count++].client = targ_p;
1108 <
1109 <  mode_changes[mode_count].letter = 'o';
1110 <  mode_changes[mode_count].dir = dir;
1111 <  mode_changes[mode_count].caps = 0;
1112 <  mode_changes[mode_count].nocaps = CAP_HOPS;
1113 <  mode_changes[mode_count].mems = ONLY_SERVERS;
1114 <  mode_changes[mode_count].id = targ_p->id;
1115 <  mode_changes[mode_count].arg = targ_p->name;
1116 <  mode_changes[mode_count++].client = targ_p;
850 >  mode_changes[mode_count].letter = c;
851 >  mode_changes[mode_count].arg = target_p->name;
852 >  mode_changes[mode_count].id = target_p->id;
853 >  mode_changes[mode_count++].dir = dir;
854  
855    if (dir == MODE_ADD)
1119 –  {
856      AddMemberFlag(member, CHFL_HALFOP);
1121 –    DelMemberFlag(member, CHFL_DEOPPED);
1122 –  }
857    else
858      DelMemberFlag(member, CHFL_HALFOP);
859   }
1126 – #endif
860  
861   static void
862 < chm_voice(struct Client *client_p, struct Client *source_p,
863 <          struct Channel *chptr, int parc, int *parn,
1131 <          char **parv, int *errors, int alev, int dir, char c, unsigned int d)
862 > chm_op(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
863 >       char **parv, int *errors, int alev, int dir, char c, unsigned int d)
864   {
865 <  const char *opnick = NULL;
1134 <  struct Client *targ_p;
865 >  struct Client *target_p;
866    struct Membership *member;
867  
868 <  if (alev < CHACCESS_HALFOP)
868 >  if (alev < CHACCESS_CHANOP)
869    {
870      if (!(*errors & SM_ERR_NOOPS))
871 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
872 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
873 <                 me.name, source_p->name, chptr->chname);
871 >      sendto_one_numeric(source_p, &me,
872 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
873 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
874      *errors |= SM_ERR_NOOPS;
875      return;
876    }
877  
878 <  if ((dir == MODE_QUERY) || parc <= *parn)
878 >  if (dir == MODE_QUERY || parc <= *parn)
879      return;
880  
881 <  opnick = parv[(*parn)++];
882 <
1152 <  if ((targ_p = find_chasing(source_p, opnick, NULL)) == NULL)
1153 <    return;
1154 <  if (!IsClient(targ_p))
1155 <    return;
881 >  if ((target_p = find_chasing(source_p, parv[(*parn)++])) == NULL)
882 >    return;  /* find_chasing sends ERR_NOSUCHNICK */
883  
884 <  if ((member = find_channel_link(targ_p, chptr)) == NULL)
884 >  if ((member = find_channel_link(target_p, chptr)) == NULL)
885    {
886      if (!(*errors & SM_ERR_NOTONCHANNEL))
887 <      sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
1161 <                 me.name, source_p->name, opnick, chptr->chname);
887 >      sendto_one_numeric(source_p, &me, ERR_USERNOTINCHANNEL, target_p->name, chptr->name);
888      *errors |= SM_ERR_NOTONCHANNEL;
889      return;
890    }
# Line 1167 | Line 893 | chm_voice(struct Client *client_p, struc
893      return;
894  
895    /* no redundant mode changes */
896 <  if (dir == MODE_ADD &&  has_member_flags(member, CHFL_VOICE))
896 >  if (dir == MODE_ADD &&  has_member_flags(member, CHFL_CHANOP))
897      return;
898 <  if (dir == MODE_DEL && !has_member_flags(member, CHFL_VOICE))
898 >  if (dir == MODE_DEL && !has_member_flags(member, CHFL_CHANOP))
899      return;
900  
901 <  mode_changes[mode_count].letter = 'v';
902 <  mode_changes[mode_count].dir = dir;
903 <  mode_changes[mode_count].caps = 0;
904 <  mode_changes[mode_count].nocaps = 0;
1179 <  mode_changes[mode_count].mems = ALL_MEMBERS;
1180 <  mode_changes[mode_count].id = targ_p->id;
1181 <  mode_changes[mode_count].arg = targ_p->name;
1182 <  mode_changes[mode_count++].client = targ_p;
901 >  mode_changes[mode_count].letter = c;
902 >  mode_changes[mode_count].arg = target_p->name;
903 >  mode_changes[mode_count].id = target_p->id;
904 >  mode_changes[mode_count++].dir = dir;
905  
906    if (dir == MODE_ADD)
907 <    AddMemberFlag(member, CHFL_VOICE);
907 >    AddMemberFlag(member, CHFL_CHANOP);
908    else
909 <    DelMemberFlag(member, CHFL_VOICE);
909 >    DelMemberFlag(member, CHFL_CHANOP);
910   }
911  
912   static void
913 < chm_limit(struct Client *client_p, struct Client *source_p,
1192 <          struct Channel *chptr, int parc, int *parn,
913 > chm_limit(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
914            char **parv, int *errors, int alev, int dir, char c, unsigned int d)
915   {
916 <  int i, limit;
1196 <  char *lstr;
916 >  int limit = 0;
917  
918    if (alev < CHACCESS_HALFOP)
919    {
920      if (!(*errors & SM_ERR_NOOPS))
921 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
922 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
923 <                 me.name, source_p->name, chptr->chname);
921 >      sendto_one_numeric(source_p, &me,
922 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
923 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
924      *errors |= SM_ERR_NOOPS;
925      return;
926    }
# Line 1208 | Line 928 | chm_limit(struct Client *client_p, struc
928    if (dir == MODE_QUERY)
929      return;
930  
931 <  if ((dir == MODE_ADD) && parc > *parn)
931 >  if (dir == MODE_ADD && parc > *parn)
932    {
933 <    lstr = parv[(*parn)++];
933 >    char *lstr = parv[(*parn)++];
934  
935 <    if ((limit = atoi(lstr)) <= 0)
935 >    if (EmptyString(lstr) || (limit = atoi(lstr)) <= 0)
936        return;
937  
938      sprintf(lstr, "%d", limit);
939  
940 <    /* if somebody sets MODE #channel +ll 1 2, accept latter --fl */
941 <    for (i = 0; i < mode_count; i++)
940 >    /* If somebody sets MODE #channel +ll 1 2, accept latter --fl */
941 >    for (unsigned int i = 0; i < mode_count; ++i)
942        if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD)
943          mode_changes[i].letter = 0;
944  
945      mode_changes[mode_count].letter = c;
946 <    mode_changes[mode_count].dir = MODE_ADD;
1227 <    mode_changes[mode_count].caps = 0;
1228 <    mode_changes[mode_count].nocaps = 0;
1229 <    mode_changes[mode_count].mems = ALL_MEMBERS;
946 >    mode_changes[mode_count].arg = lstr;
947      mode_changes[mode_count].id = NULL;
948 <    mode_changes[mode_count++].arg = lstr;
948 >    mode_changes[mode_count++].dir = dir;
949  
950      chptr->mode.limit = limit;
951    }
# Line 1240 | Line 957 | chm_limit(struct Client *client_p, struc
957      chptr->mode.limit = 0;
958  
959      mode_changes[mode_count].letter = c;
960 <    mode_changes[mode_count].dir = MODE_DEL;
1244 <    mode_changes[mode_count].caps = 0;
1245 <    mode_changes[mode_count].nocaps = 0;
1246 <    mode_changes[mode_count].mems = ALL_MEMBERS;
960 >    mode_changes[mode_count].arg = NULL;
961      mode_changes[mode_count].id = NULL;
962 <    mode_changes[mode_count++].arg = NULL;
962 >    mode_changes[mode_count++].dir = dir;
963    }
964   }
965  
966   static void
967 < chm_key(struct Client *client_p, struct Client *source_p,
1254 <        struct Channel *chptr, int parc, int *parn,
967 > chm_key(struct Client *source_p, struct Channel *chptr, int parc, int *parn,
968          char **parv, int *errors, int alev, int dir, char c, unsigned int d)
969   {
1257 –  int i;
1258 –  char *key;
1259 –
970    if (alev < CHACCESS_HALFOP)
971    {
972      if (!(*errors & SM_ERR_NOOPS))
973 <      sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?
974 <                                    ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),
975 <                 me.name, source_p->name, chptr->chname);
973 >      sendto_one_numeric(source_p, &me,
974 >                         alev == CHACCESS_NOTONCHAN ? ERR_NOTONCHANNEL :
975 >                         ERR_CHANOPRIVSNEEDED, chptr->name);
976      *errors |= SM_ERR_NOOPS;
977      return;
978    }
# Line 1270 | Line 980 | chm_key(struct Client *client_p, struct
980    if (dir == MODE_QUERY)
981      return;
982  
983 <  if ((dir == MODE_ADD) && parc > *parn)
983 >  if (dir == MODE_ADD && parc > *parn)
984    {
985 <    key = parv[(*parn)++];
985 >    char *key = fix_key(parv[(*parn)++]);
986  
987 <    if (MyClient(source_p))
1278 <      fix_key(key);
1279 <    else
1280 <      fix_key_old(key);
1281 <
1282 <    if (*key == '\0')
987 >    if (EmptyString(key))
988        return;
989  
990      assert(key[0] != ' ');
991      strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key));
992  
993 <    /* if somebody does MODE #channel +kk a b, accept latter --fl */
994 <    for (i = 0; i < mode_count; i++)
993 >    /* If somebody does MODE #channel +kk a b, accept latter --fl */
994 >    for (unsigned int i = 0; i < mode_count; ++i)
995        if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD)
996          mode_changes[i].letter = 0;
997  
998      mode_changes[mode_count].letter = c;
999 <    mode_changes[mode_count].dir = MODE_ADD;
1295 <    mode_changes[mode_count].caps = 0;
1296 <    mode_changes[mode_count].nocaps = 0;
1297 <    mode_changes[mode_count].mems = ALL_MEMBERS;
999 >    mode_changes[mode_count].arg = chptr->mode.key;
1000      mode_changes[mode_count].id = NULL;
1001 <    mode_changes[mode_count++].arg = chptr->mode.key;
1001 >    mode_changes[mode_count++].dir = dir;
1002    }
1003    else if (dir == MODE_DEL)
1004    {
1005      if (parc > *parn)
1006 <      (*parn)++;
1006 >      ++(*parn);
1007  
1008      if (chptr->mode.key[0] == '\0')
1009        return;
# Line 1309 | Line 1011 | chm_key(struct Client *client_p, struct
1011      chptr->mode.key[0] = '\0';
1012  
1013      mode_changes[mode_count].letter = c;
1014 <    mode_changes[mode_count].dir = MODE_DEL;
1313 <    mode_changes[mode_count].caps = 0;
1314 <    mode_changes[mode_count].nocaps = 0;
1315 <    mode_changes[mode_count].mems = ALL_MEMBERS;
1014 >    mode_changes[mode_count].arg = "*";
1015      mode_changes[mode_count].id = NULL;
1016 <    mode_changes[mode_count++].arg = "*";
1016 >    mode_changes[mode_count++].dir = dir;
1017    }
1018   }
1019  
1020 < struct ChannelMode
1322 < {
1323 <  void (*func)(struct Client *, struct Client *,
1324 <               struct Channel *, int, int *, char **,
1325 <               int *, int, int, char, unsigned int);
1326 <  unsigned int d;
1327 < };
1328 <
1329 < static struct ChannelMode ModeTable[256] =
1020 > const struct ChannelMode ModeTable[256] =
1021   {
1022    { chm_nosuch,  0 },                   /* 0x00 */
1023    { chm_nosuch,  0 },                   /* 0x01 */
# Line 1432 | Line 1123 | static struct ChannelMode ModeTable[256]
1123    { chm_except,  0 },                   /* e */
1124    { chm_nosuch,  0 },                   /* f */
1125    { chm_nosuch,  0 },                   /* g */
1435 – #ifdef HALFOPS
1126    { chm_hop,     0 },                   /* h */
1437 – #else
1438 –  { chm_nosuch,  0 },                   /* h */
1439 – #endif
1127    { chm_simple,     MODE_INVITEONLY },  /* i */
1128    { chm_nosuch,     0               },  /* j */
1129    { chm_key,        0               },  /* k */
# Line 1599 | Line 1286 | static struct ChannelMode ModeTable[256]
1286   * side effects - NONE
1287   */
1288   static int
1289 < get_channel_access(struct Client *source_p, struct Membership *member)
1289 > get_channel_access(const struct Client *source_p,
1290 >                   const struct Membership *member)
1291   {
1292    /* Let hacked servers in for now... */
1293    if (!MyClient(source_p))
1294 <    return CHACCESS_CHANOP;
1294 >    return CHACCESS_REMOTE;
1295  
1296 <  if (member == NULL)
1296 >  if (!member)
1297      return CHACCESS_NOTONCHAN;
1298  
1299 <  /* just to be sure.. */
1299 >  /* Just to be sure.. */
1300    assert(source_p == member->client_p);
1301  
1302    if (has_member_flags(member, CHFL_CHANOP))
1303      return CHACCESS_CHANOP;
1304  
1617 – #ifdef HALFOPS
1305    if (has_member_flags(member, CHFL_HALFOP))
1306      return CHACCESS_HALFOP;
1620 – #endif
1307  
1308    return CHACCESS_PEON;
1309   }
1310  
1311 < /* void send_cap_mode_changes(struct Client *client_p,
1312 < *                        struct Client *source_p,
1627 < *                        struct Channel *chptr, int cap, int nocap)
1628 < * Input: The client sending(client_p), the source client(source_p),
1311 > /* send_mode_changes_server()
1312 > * Input: the source client(source_p),
1313   *        the channel to send mode changes for(chptr)
1314   * Output: None.
1315 < * Side-effects: Sends the appropriate mode changes to capable servers.
1315 > * Side-effects: Sends the appropriate mode changes to servers.
1316   *
1633 – * send_cap_mode_changes() will loop the server list itself, because
1634 – * at this point in time we have 4 capabs for channels, CAP_IE, CAP_EX,
1635 – * and a server could support any number of these..
1636 – * so we make the modebufs per server, tailoring them to each servers
1637 – * specific demand.  Its not very pretty, but its one of the few realistic
1638 – * ways to handle having this many capabs for channel modes.. --fl_
1639 – *
1640 – * Reverted back to my original design, except that we now keep a count
1641 – * of the number of servers which each combination as an optimisation, so
1642 – * the capabs combinations which are not needed are not worked out. -A1kmm
1317   */
1644 – /* rewritten to ensure parabuf < MODEBUFLEN -db */
1645 –
1318   static void
1319 < send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
1648 <                      struct Channel *chptr, unsigned int cap, unsigned int nocap)
1319 > send_mode_changes_server(struct Client *source_p, struct Channel *chptr)
1320   {
1321 <  int i, mbl, pbl, arglen, nc, mc;
1322 <  int len;
1652 <  const char *arg = NULL;
1653 <  char *parptr;
1321 >  int mbl = 0, pbl = 0, arglen = 0, nc = 0, mc = 0;
1322 >  int len = 0;
1323    int dir = MODE_QUERY;
1324 <
1325 <  mc = 0;
1657 <  nc = 0;
1658 <  pbl = 0;
1324 >  const char *arg = NULL;
1325 >  char *parptr = NULL;
1326  
1327    parabuf[0] = '\0';
1328    parptr = parabuf;
1329  
1330 <  if ((cap & CAP_TS6) && source_p->id[0] != '\0')
1331 <    mbl = sprintf(modebuf, ":%s TMODE %lu %s ", source_p->id,
1665 <                  (unsigned long)chptr->channelts, chptr->chname);
1666 <  else
1667 <    mbl = sprintf(modebuf, ":%s MODE %s ", source_p->name,
1668 <                  chptr->chname);
1330 >  mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id,
1331 >                 (unsigned long)chptr->channelts, chptr->name);
1332  
1333 <  /* loop the list of - modes we have */
1334 <  for (i = 0; i < mode_count; i++)
1333 >  /* Loop the list of modes we have */
1334 >  for (unsigned i = 0; i < mode_count; ++i)
1335    {
1336 <    /* if they dont support the cap we need, or they do support a cap they
1674 <     * cant have, then dont add it to the modebuf.. that way they wont see
1675 <     * the mode
1676 <     */
1677 <    if ((mode_changes[i].letter == 0) ||
1678 <        ((cap & mode_changes[i].caps) != mode_changes[i].caps) ||
1679 <        ((nocap & mode_changes[i].nocaps) != mode_changes[i].nocaps))
1336 >    if (mode_changes[i].letter == 0)
1337        continue;
1338  
1339 <    arg = "";
1683 <
1684 <    if ((cap & CAP_TS6) && mode_changes[i].id)
1339 >    if (mode_changes[i].id)
1340        arg = mode_changes[i].id;
1341 <    if (*arg == '\0')
1341 >    else
1342        arg = mode_changes[i].arg;
1343  
1344 <    /* if we're creeping past the buf size, we need to send it and make
1690 <     * another line for the other modes
1691 <     * XXX - this could give away server topology with uids being
1692 <     * different lengths, but not much we can do, except possibly break
1693 <     * them as if they were the longest of the nick or uid at all times,
1694 <     * which even then won't work as we don't always know the uid -A1kmm.
1695 <     */
1696 <    if (arg != NULL)
1344 >    if (arg)
1345        arglen = strlen(arg);
1346      else
1347        arglen = 0;
1348  
1349 +    /*
1350 +     * If we're creeping past the buf size, we need to send it and make
1351 +     * another line for the other modes
1352 +     */
1353      if ((mc == MAXMODEPARAMS) ||
1354          ((arglen + mbl + pbl + 2) > IRCD_BUFSIZE) ||
1355          (pbl + arglen + BAN_FUDGE) >= MODEBUFLEN)
1356      {
1357 <      if (nc != 0)
1358 <        sendto_server(client_p, cap, nocap, "%s %s", modebuf, parabuf);
1357 >      if (nc)
1358 >        sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1359 >
1360        nc = 0;
1361        mc = 0;
1362  
1363 <      if ((cap & CAP_TS6) && source_p->id[0] != '\0')
1364 <        mbl = sprintf(modebuf, ":%s MODE %s ", source_p->id,
1712 <                      chptr->chname);
1713 <      else
1714 <        mbl = sprintf(modebuf, ":%s MODE %s ", source_p->name,
1715 <                      chptr->chname);
1363 >      mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id,
1364 >                     (unsigned long)chptr->channelts, chptr->name);
1365  
1366        pbl = 0;
1367        parabuf[0] = '\0';
# Line 1728 | Line 1377 | send_cap_mode_changes(struct Client *cli
1377  
1378      modebuf[mbl++] = mode_changes[i].letter;
1379      modebuf[mbl] = '\0';
1380 <    nc++;
1380 >    ++nc;
1381  
1382 <    if (arg != NULL)
1382 >    if (arg)
1383      {
1384        len = sprintf(parptr, "%s ", arg);
1385        pbl += len;
1386        parptr += len;
1387 <      mc++;
1387 >      ++mc;
1388      }
1389    }
1390  
1391    if (pbl && parabuf[pbl - 1] == ' ')
1392 <    parabuf[pbl - 1] = 0;
1392 >    parabuf[pbl - 1] = '\0';
1393  
1394 <  if (nc != 0)
1395 <    sendto_server(client_p, cap, nocap, "%s %s", modebuf, parabuf);
1394 >  if (nc)
1395 >    sendto_server(source_p, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
1396   }
1397  
1398   /* void send_mode_changes(struct Client *client_p,
# Line 1758 | Line 1407 | send_cap_mode_changes(struct Client *cli
1407   */
1408   /* ensure parabuf < MODEBUFLEN -db */
1409   static void
1410 < send_mode_changes(struct Client *client_p, struct Client *source_p,
1762 <                  struct Channel *chptr)
1410 > send_mode_changes(struct Client *source_p, struct Channel *chptr)
1411   {
1412 <  int i, mbl, pbl, arglen, nc, mc;
1413 <  int len;
1766 <  const char *arg = NULL;
1767 <  char *parptr;
1412 >  int mbl = 0, pbl = 0, arglen = 0, nc = 0, mc = 0;
1413 >  int len = 0;
1414    int dir = MODE_QUERY;
1415 +  const char *arg = NULL;
1416 +  char *parptr = NULL;
1417  
1418 <  /* bail out if we have nothing to do... */
1418 >  /* Bail out if we have nothing to do... */
1419    if (!mode_count)
1420      return;
1421  
1422    if (IsServer(source_p))
1423 <    mbl = sprintf(modebuf, ":%s MODE %s ", (IsHidden(source_p) ||
1424 <                  ConfigServerHide.hide_servers) ?
1425 <                  me.name : source_p->name, chptr->chname);
1423 >    mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1424 >                   ConfigServerHide.hide_servers) ?
1425 >                   me.name : source_p->name, chptr->name);
1426    else
1427 <    mbl = sprintf(modebuf, ":%s!%s@%s MODE %s ", source_p->name,
1428 <                  source_p->username, source_p->host, chptr->chname);
1781 <
1782 <  mc = 0;
1783 <  nc = 0;
1784 <  pbl = 0;
1427 >    mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1428 >                   source_p->username, source_p->host, chptr->name);
1429  
1430    parabuf[0] = '\0';
1431    parptr = parabuf;
1432  
1433 <  for (i = 0; i < mode_count; i++)
1433 >  for (unsigned int i = 0; i < mode_count; ++i)
1434    {
1435 <    if (mode_changes[i].letter == 0 ||
1792 <        mode_changes[i].mems == NON_CHANOPS ||
1793 <        mode_changes[i].mems == ONLY_SERVERS)
1435 >    if (mode_changes[i].letter == 0)
1436        continue;
1437  
1438      arg = mode_changes[i].arg;
1439 <    if (arg != NULL)
1439 >    if (arg)
1440        arglen = strlen(arg);
1441      else
1442        arglen = 0;
1443  
1444 <    if ((mc == MAXMODEPARAMS)  ||
1444 >    if ((mc == MAXMODEPARAMS) ||
1445          ((arglen + mbl + pbl + 2) > IRCD_BUFSIZE) ||
1446          ((arglen + pbl + BAN_FUDGE) >= MODEBUFLEN))
1447      {
1448        if (mbl && modebuf[mbl - 1] == '-')
1449          modebuf[mbl - 1] = '\0';
1450  
1451 <      if (nc != 0)
1452 <        sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf);
1451 >      if (nc)
1452 >        sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf);
1453  
1454        nc = 0;
1455        mc = 0;
1456  
1457        if (IsServer(source_p))
1458 <        mbl = sprintf(modebuf, ":%s MODE %s ", (IsHidden(source_p) ||
1459 <                      ConfigServerHide.hide_servers) ?
1460 <                      me.name : source_p->name, chptr->chname);
1458 >        mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1459 >                       ConfigServerHide.hide_servers) ?
1460 >                       me.name : source_p->name, chptr->name);
1461        else
1462 <        mbl = sprintf(modebuf, ":%s!%s@%s MODE %s ", source_p->name,
1463 <                      source_p->username, source_p->host, chptr->chname);
1462 >        mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1463 >                       source_p->username, source_p->host, chptr->name);
1464  
1465        pbl = 0;
1466        parabuf[0] = '\0';
# Line 1834 | Line 1476 | send_mode_changes(struct Client *client_
1476  
1477      modebuf[mbl++] = mode_changes[i].letter;
1478      modebuf[mbl] = '\0';
1479 <    nc++;
1479 >    ++nc;
1480  
1481 <    if (arg != NULL)
1481 >    if (arg)
1482      {
1483        len = sprintf(parptr, "%s ", arg);
1484        pbl += len;
1485        parptr += len;
1486 <      mc++;
1486 >      ++mc;
1487      }
1488    }
1489  
1490    if (pbl && parabuf[pbl - 1] == ' ')
1491 <    parabuf[pbl - 1] = 0;
1491 >    parabuf[pbl - 1] = '\0';
1492  
1493 <  if (nc != 0)
1494 <    sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf);
1493 >  if (nc)
1494 >    sendto_channel_local(0, chptr, "%s %s", modebuf, parabuf);
1495  
1496 <  nc = 0;
1497 <  mc = 0;
1496 >  send_mode_changes_server(source_p, chptr);
1497 > }
1498  
1499 <  /* Now send to servers... */
1500 <  for (i = 0; i < NCHCAP_COMBOS; i++)
1859 <    if (chcap_combos[i].count != 0)
1860 <      send_cap_mode_changes(client_p, source_p, chptr,
1861 <                            chcap_combos[i].cap_yes,
1862 <                            chcap_combos[i].cap_no);
1863 < }
1864 <
1865 < /* void set_channel_mode(struct Client *client_p, struct Client *source_p,
1866 < *               struct Channel *chptr, int parc, char **parv,
1867 < *               char *chname)
1868 < * Input: The client we received this from, the client this originated
1499 > /*
1500 > * Input: The the client this originated
1501   *        from, the channel, the parameter count starting at the modes,
1502   *        the parameters, the channel name.
1503   * Output: None.
# Line 1874 | Line 1506 | send_mode_changes(struct Client *client_
1506   *               clients.
1507   */
1508   void
1509 < set_channel_mode(struct Client *client_p, struct Client *source_p, struct Channel *chptr,
1509 > set_channel_mode(struct Client *source_p, struct Channel *chptr,
1510                   struct Membership *member, int parc, char *parv[])
1511   {
1512    int dir = MODE_ADD;
1513    int parn = 1;
1514 <  int alevel, errors = 0;
1883 <  char *ml = parv[0], c;
1514 >  int alevel = 0, errors = 0;
1515  
1516    mode_count = 0;
1517    mode_limit = 0;
# Line 1888 | Line 1519 | set_channel_mode(struct Client *client_p
1519  
1520    alevel = get_channel_access(source_p, member);
1521  
1522 <  for (; (c = *ml); ++ml)
1522 >  for (const char *ml = parv[0]; *ml; ++ml)
1523    {
1524 <    switch (c)
1524 >    switch (*ml)
1525      {
1526        case '+':
1527          dir = MODE_ADD;
# Line 1903 | Line 1534 | set_channel_mode(struct Client *client_p
1534          break;
1535        default:
1536        {
1537 <        struct ChannelMode *tptr = &ModeTable[(unsigned char)c];
1537 >        const struct ChannelMode *tptr = &ModeTable[(unsigned char)*ml];
1538  
1539 <        tptr->func(client_p, source_p, chptr, parc, &parn,
1540 <                   parv, &errors, alevel, dir, c, tptr->d);
1539 >        tptr->func(source_p, chptr, parc, &parn, parv,
1540 >                   &errors, alevel, dir, *ml, tptr->d);
1541          break;
1542        }
1543      }
1544    }
1545  
1546 <  send_mode_changes(client_p, source_p, chptr);
1546 >  send_mode_changes(source_p, chptr);
1547   }

Diff Legend

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