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

Comparing ircd-hybrid/trunk/modules/m_svsmode.c (file contents):
Revision 2246 by michael, Sun Jun 16 10:48:39 2013 UTC vs.
Revision 3479 by michael, Sun May 4 16:49:06 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 1999 by the Bahamut Development Team.
5 < *  Copyright (C) 2011 by the Hybrid Development Team.
4 > *  Copyright (c) 1999 Bahamut development team.
5 > *  Copyright (c) 2011-2014 ircd-hybrid development team
6   *
7   *  This program is free software; you can redistribute it and/or modify
8   *  it under the terms of the GNU General Public License as published by
# Line 28 | Line 28
28   #include "stdinc.h"
29   #include "client.h"
30   #include "ircd.h"
31 < #include "numeric.h"
32 < #include "s_serv.h"
31 > #include "server.h"
32   #include "send.h"
33   #include "channel_mode.h"
34   #include "parse.h"
35   #include "modules.h"
36   #include "irc_string.h"
37 < #include "s_user.h"
37 > #include "user.h"
38   #include "conf.h"
40 – #include "hook.h"
39  
40  
41 < /*! \brief SVSMODE command handler (called by services)
41 > /*! \brief SVSMODE command handler
42   *
45 – * \param client_p Pointer to allocated Client struct with physical connection
46 – *                 to this server, i.e. with an open socket connected.
43   * \param source_p Pointer to allocated Client struct from which the message
44   *                 originally comes from.  This can be a local or remote client.
45   * \param parc     Integer holding the number of supplied arguments.
46   * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
47   *                 pointers.
48   * \note Valid arguments for this command are:
49 < *      - parv[0] = sender prefix
49 > *      - parv[0] = command
50   *      - parv[1] = nickname
51   *      - parv[2] = TS (or mode, depending on svs version)
52   *      - parv[3] = mode (or services id if old svs version)
53   *      - parv[4] = optional argument (services id)
54   */
55 < static void
56 < ms_svsmode(struct Client *client_p, struct Client *source_p,
61 <           int parc, char *parv[])
55 > static int
56 > ms_svsmode(struct Client *source_p, int parc, char *parv[])
57   {
58    struct Client *target_p = NULL;
59    int what = MODE_ADD;
60    unsigned int flag = 0, setmodes = 0;
61 <  char *m = NULL, *modes = NULL, *extarg = NULL;
61 >  const char *modes = NULL, *extarg = NULL;
62    time_t ts = 0;
63  
64    if (!HasFlag(source_p, FLAGS_SERVICE))
65 <    return;
65 >    return 0;
66  
67    if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
68    {
# Line 81 | Line 76 | ms_svsmode(struct Client *client_p, stru
76      extarg = (parc > 3) ? parv[3] : NULL;
77    }
78  
79 <  if ((target_p = find_person(client_p, parv[1])) == NULL)
80 <    return;
79 >  if ((target_p = find_person(source_p, parv[1])) == NULL)
80 >    return 0;
81  
82    if (ts && (ts != target_p->tsinfo))
83 <    return;
83 >    return 0;
84  
85    setmodes = target_p->umodes;
86  
87 <  for (m = modes; *m; ++m)
87 >  for (const char *m = modes; *m; ++m)
88    {
89      switch (*m)
90      {
# Line 114 | Line 109 | ms_svsmode(struct Client *client_p, stru
109          if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
110          {
111            ClearOper(target_p);
112 <          Count.oper--;
112 >          --Count.oper;
113  
114            if (MyConnect(target_p))
115            {
# Line 123 | Line 118 | ms_svsmode(struct Client *client_p, stru
118              detach_conf(target_p, CONF_OPER);
119              ClrOFlag(target_p);
120              DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
121 <
122 <           if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
123 <             free_dlink_node(dm);
121 >
122 >            if ((dm = dlinkFindDelete(&oper_list, target_p)))
123 >              free_dlink_node(dm);
124            }
125          }
126  
# Line 147 | Line 142 | ms_svsmode(struct Client *client_p, stru
142          break;
143  
144        case 'S':  /* Only servers may set +S in a burst */
145 +      case 'W':  /* Only servers may set +W in a burst */
146          break;
147  
148        default:
# Line 163 | Line 159 | ms_svsmode(struct Client *client_p, stru
159    }
160  
161    if (extarg)
162 <  {
163 <    sendto_server(client_p, CAP_TS6, NOCAPS,
164 <                  ":%s SVSMODE %s %lu %s %s", ID(source_p),
169 <                  ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg);
170 <    sendto_server(client_p, NOCAPS, CAP_TS6,
171 <                  ":%s SVSMODE %s %lu %s %s", source_p->name,
172 <                  target_p->name, (unsigned long)target_p->tsinfo, modes, extarg);
173 <  }
162 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%s SVSMODE %s %lu %s %s",
163 >                  source_p->id,
164 >                  target_p->id, (unsigned long)target_p->tsinfo, modes, extarg);
165    else
166 <  {
167 <    sendto_server(client_p, CAP_TS6, NOCAPS,
168 <                  ":%s SVSMODE %s %lu %s", ID(source_p),
178 <                  ID(target_p), (unsigned long)target_p->tsinfo, modes);
179 <    sendto_server(client_p, NOCAPS, CAP_TS6,
180 <                  ":%s SVSMODE %s %lu %s", source_p->name,
181 <                  target_p->name, (unsigned long)target_p->tsinfo, modes);
182 <  }
166 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%s SVSMODE %s %lu %s",
167 >                  source_p->id,
168 >                  target_p->id, (unsigned long)target_p->tsinfo, modes);
169  
170    if (MyConnect(target_p) && (setmodes != target_p->umodes))
171    {
172 <    char modebuf[IRCD_BUFSIZE];
172 >    char modebuf[IRCD_BUFSIZE] = "";
173  
174      send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf);
175    }
176 +
177 +  return 0;
178   }
179  
180 < static struct Message svsmode_msgtab = {
180 > static struct Message svsmode_msgtab =
181 > {
182    "SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
183 <  {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
183 >  { m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore }
184   };
185  
186   static void
# Line 206 | Line 195 | module_exit(void)
195    mod_del_cmd(&svsmode_msgtab);
196   }
197  
198 < struct module module_entry = {
198 > struct module module_entry =
199 > {
200    .node    = { NULL, NULL, NULL },
201    .name    = NULL,
202    .version = "$Revision$",

Diff Legend

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