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-8/modules/m_svsmode.c (file contents), Revision 1163 by michael, Wed Aug 10 21:54:01 2011 UTC vs.
ircd-hybrid/trunk/modules/m_svsmode.c (file contents), Revision 5550 by michael, Thu Feb 12 15:52:10 2015 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-2015 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 16 | Line 16
16   *
17   *  You should have received a copy of the GNU General Public License
18   *  along with this program; if not, write to the Free Software
19 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20   *  USA
21   */
22  
# Line 26 | Line 26
26   */
27  
28   #include "stdinc.h"
29 – #include "handlers.h"
29   #include "client.h"
30   #include "ircd.h"
32 – #include "numeric.h"
33 – #include "s_conf.h"
34 – #include "s_serv.h"
31   #include "send.h"
32   #include "channel_mode.h"
37 – #include "msg.h"
33   #include "parse.h"
34   #include "modules.h"
35   #include "irc_string.h"
36 < #include "s_user.h"
36 > #include "user.h"
37 > #include "conf.h"
38  
43 – static void ms_svsmode(struct Client *, struct Client *, int, char *[]);
39  
40 < struct Message svsmode_msgtab = {
46 <  "SVSMODE", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
47 <  {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
48 < };
49 <
50 < const char *_version = "$Revision$";
51 <
52 < void
53 < _modinit(void)
54 < {
55 <  mod_add_cmd(&svsmode_msgtab);
56 < }
57 <
58 < void
59 < _moddeinit(void)
60 < {
61 <  mod_del_cmd(&svsmode_msgtab);
62 < }
63 <
64 <
65 < /*! \brief SVSMODE command handler (called by servers or services)
40 > /*! \brief SVSMODE command handler
41   *
67 – * \param client_p Pointer to allocated Client struct with physical connection
68 – *                 to this server, i.e. with an open socket connected.
42   * \param source_p Pointer to allocated Client struct from which the message
43   *                 originally comes from.  This can be a local or remote client.
44   * \param parc     Integer holding the number of supplied arguments.
45   * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
46   *                 pointers.
47   * \note Valid arguments for this command are:
48 < *      - parv[0] = sender prefix
48 > *      - parv[0] = command
49   *      - parv[1] = nickname
50 < *      - parv[2] = TS (or mode, depending on svs version)
51 < *      - parv[3] = mode (or services id if old svs version)
52 < *      - parv[4] = optional arguement (services id)
50 > *      - parv[2] = TS
51 > *      - parv[3] = mode
52 > *      - parv[4] = optional argument (services account, vhost)
53   */
54 < static void
55 < ms_svsmode(struct Client *client_p, struct Client *source_p,
83 <           int parc, char *parv[])
54 > static int
55 > ms_svsmode(struct Client *source_p, int parc, char *parv[])
56   {
57 +  const struct user_modes *tab = NULL;
58    struct Client *target_p = NULL;
59    int what = MODE_ADD;
60 <  unsigned int flag = 0, setflags = 0;
61 <  char *m = NULL, *modes = NULL, *extarg = NULL;
60 >  unsigned int setmodes = 0;
61 >  const char *modes = NULL, *extarg = NULL;
62    time_t ts = 0;
63  
64 <  if (!IsService(source_p) || (parc < 3))
65 <    return;
64 >  if (!HasFlag(source_p, FLAGS_SERVICE))
65 >    return 0;
66  
67 <  if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
68 <  {
69 <    ts     = atol(parv[2]);
97 <    modes  = parv[3];
98 <    extarg = (parc > 4) ? parv[4] : NULL;
99 <  }
100 <  else
101 <  {
102 <    modes  = parv[2];
103 <    extarg = (parc > 3) ? parv[3] : NULL;
104 <  }
67 >  ts     = atol(parv[2]);
68 >  modes  = parv[3];
69 >  extarg = (parc > 4) ? parv[4] : NULL;
70  
71 <  if ((target_p = find_person(client_p, parv[1])) == NULL)
72 <    return;
71 >  if ((target_p = find_person(source_p, parv[1])) == NULL)
72 >    return 0;
73  
74    if (ts && (ts != target_p->tsinfo))
75 <    return;
75 >    return 0;
76  
77 <  setflags = target_p->umodes;
77 >  setmodes = target_p->umodes;
78  
79 <  for (m = modes; *m; ++m)
79 >  for (const char *m = modes; *m; ++m)
80    {
81      switch (*m)
82      {
# Line 123 | Line 88 | ms_svsmode(struct Client *client_p, stru
88          break;
89  
90        case 'd':
91 <        if (extarg && IsDigit(*extarg))
92 <          target_p->servicestamp = strtoul(extarg, NULL, 0);
91 >        if (!EmptyString(extarg))
92 >          strlcpy(target_p->account, extarg, sizeof(target_p->account));
93 >        break;
94 >
95 >      case 'x':
96 >        if (!EmptyString(extarg) && valid_hostname(extarg))
97 >          user_set_hostmask(target_p, extarg, what);
98          break;
99  
100        case 'o':
101 <        if (what == MODE_DEL && IsOper(target_p))
101 >        if (what == MODE_DEL && HasUMode(target_p, UMODE_OPER))
102          {
103            ClearOper(target_p);
104 <          Count.oper--;
104 >          --Count.oper;
105  
106            if (MyConnect(target_p))
107            {
108 <            dlink_node *dm = NULL;
108 >            dlink_node *node = NULL;
109 >
110 >            detach_conf(target_p, CONF_OPER);
111 >            ClrOFlag(target_p);
112 >            DelUMode(target_p, ConfigGeneral.oper_only_umodes);
113  
114 <            detach_conf(target_p, OPER_TYPE);
115 <            ClearOperFlags(target_p);
142 <            DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
143 <
144 <           if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
145 <             free_dlink_node(dm);
114 >            if ((node = dlinkFindDelete(&oper_list, target_p)))
115 >              free_dlink_node(node);
116            }
117          }
118  
# Line 163 | Line 133 | ms_svsmode(struct Client *client_p, stru
133  
134          break;
135  
136 <      case ' ':
137 <      case '\n':
168 <      case '\r':
169 <      case '\t':
136 >      case 'S':  /* Only servers may set +S in a burst */
137 >      case 'W':  /* Only servers may set +W in a burst */
138          break;
139 +
140        default:
141 <        if ((flag = user_modes[(unsigned char)*m]))
142 <          execute_callback(umode_cb, client_p, target_p, what, flag);
141 >        if ((tab = umode_map[(unsigned char)*m]))
142 >        {
143 >          if (what == MODE_ADD)
144 >            AddUMode(target_p, tab->flag);
145 >          else
146 >            DelUMode(target_p, tab->flag);
147 >        }
148 >
149          break;
150      }
151    }
152  
153    if (extarg)
154 <  {
155 <    sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
156 <                  ":%s SVSMODE %s %lu %s %s", ID(source_p),
182 <                  ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg);
183 <    sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
184 <                  ":%s SVSMODE %s %lu %s %s", source_p->name,
185 <                  target_p->name, (unsigned long)target_p->tsinfo, modes, extarg);
186 <  }
154 >    sendto_server(source_p, 0, 0, ":%s SVSMODE %s %lu %s %s",
155 >                  source_p->id,
156 >                  target_p->id, (unsigned long)target_p->tsinfo, modes, extarg);
157    else
158 <  {
159 <    sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
160 <                  ":%s SVSMODE %s %lu %s", ID(source_p),
191 <                  ID(target_p), (unsigned long)target_p->tsinfo, modes);
192 <    sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
193 <                  ":%s SVSMODE %s %lu %s", source_p->name,
194 <                  target_p->name, (unsigned long)target_p->tsinfo, modes);
195 <  }
158 >    sendto_server(source_p, 0, 0, ":%s SVSMODE %s %lu %s",
159 >                  source_p->id,
160 >                  target_p->id, (unsigned long)target_p->tsinfo, modes);
161  
162 <  if (MyConnect(target_p) && (setflags != target_p->umodes))
162 >  if (MyConnect(target_p) && (setmodes != target_p->umodes))
163    {
164 <    char modebuf[IRCD_BUFSIZE];
164 >    char modebuf[IRCD_BUFSIZE] = "";
165  
166 <    send_umode(target_p, target_p, setflags, 0xffffffff, modebuf);
166 >    send_umode(target_p, target_p, setmodes, modebuf);
167    }
168 +
169 +  return 0;
170   }
171 +
172 + static struct Message svsmode_msgtab =
173 + {
174 +  "SVSMODE", NULL, 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
175 +  { m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore }
176 + };
177 +
178 + static void
179 + module_init(void)
180 + {
181 +  mod_add_cmd(&svsmode_msgtab);
182 + }
183 +
184 + static void
185 + module_exit(void)
186 + {
187 +  mod_del_cmd(&svsmode_msgtab);
188 + }
189 +
190 + struct module module_entry =
191 + {
192 +  .node    = { NULL, NULL, NULL },
193 +  .name    = NULL,
194 +  .version = "$Revision$",
195 +  .handle  = NULL,
196 +  .modinit = module_init,
197 +  .modexit = module_exit,
198 +  .flags   = 0
199 + };

Comparing:
ircd-hybrid-8/modules/m_svsmode.c (property svn:eol-style), Revision 1163 by michael, Wed Aug 10 21:54:01 2011 UTC vs.
ircd-hybrid/trunk/modules/m_svsmode.c (property svn:eol-style), Revision 5550 by michael, Thu Feb 12 15:52:10 2015 UTC

# Line 0 | Line 1
1 + native

Diff Legend

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