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 2025 by michael, Sun May 12 18:54:15 2013 UTC vs.
Revision 3561 by michael, Fri May 16 13:51:39 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
52   *      - parv[3] = mode
53 < *      - parv[4] = optional argument (services id, hostname)
53 > *      - parv[4] = optional argument (services id, vhost)
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;
64 –  const char *m = NULL, *extarg = NULL;
59    int what = MODE_ADD;
60 <  unsigned int flag = 0, setflags = 0;
60 >  unsigned int flag = 0, setmodes = 0;
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 ((target_p = find_person(client_p, parv[1])) == NULL)
68 <    return;
67 >  ts     = atol(parv[2]);
68 >  modes  = parv[3];
69 >  extarg = (parc > 4) ? parv[4] : NULL;
70  
71 <  if ((ts = atol(parv[2])) && (ts != target_p->tsinfo))
72 <    return;
71 >  if ((target_p = find_person(source_p, parv[1])) == NULL)
72 >    return 0;
73  
74 <  if (parc > 4 && !EmptyString(parv[4]))
75 <    extarg = parv[4];
74 >  if (ts && (ts != target_p->tsinfo))
75 >    return 0;
76  
77 <  setflags = target_p->umodes;
77 >  setmodes = target_p->umodes;
78  
79 <  for (m = parv[3]; *m; ++m)
79 >  for (const char *m = modes; *m; ++m)
80    {
81      switch (*m)
82      {
# Line 92 | Line 88 | ms_svsmode(struct Client *client_p, stru
88          break;
89  
90        case 'd':
91 <        if (extarg)
91 >        if (!EmptyString(extarg))
92            strlcpy(target_p->svid, extarg, sizeof(target_p->svid));
93          break;
94  
95        case 'x':
96 <        if (what == MODE_ADD && extarg)
97 <          user_set_hostmask(target_p, extarg);
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 && HasUMode(target_p, UMODE_OPER))
102          {
103            ClearOper(target_p);
104 <          Count.oper--;
104 >          --Count.oper;
105  
106            if (MyConnect(target_p))
107            {
# Line 114 | Line 110 | ms_svsmode(struct Client *client_p, stru
110              detach_conf(target_p, CONF_OPER);
111              ClrOFlag(target_p);
112              DelUMode(target_p, ConfigFileEntry.oper_only_umodes);
113 <
114 <           if ((dm = dlinkFindDelete(&oper_list, target_p)) != NULL)
115 <             free_dlink_node(dm);
113 >
114 >            if ((dm = dlinkFindDelete(&oper_list, target_p)))
115 >              free_dlink_node(dm);
116            }
117          }
118  
# Line 137 | Line 133 | ms_svsmode(struct Client *client_p, stru
133  
134          break;
135  
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          {
# Line 151 | Line 151 | ms_svsmode(struct Client *client_p, stru
151    }
152  
153    if (extarg)
154 <  {
155 <    sendto_server(client_p, CAP_TS6, NOCAPS,
156 <                  ":%s SVSMODE %s %lu %s %s", ID(source_p),
157 <                  ID(target_p), (unsigned long)target_p->tsinfo, parv[3], extarg);
158 <    sendto_server(client_p, NOCAPS, CAP_TS6,
159 <                  ":%s SVSMODE %s %lu %s %s", source_p->name,
160 <                  target_p->name, (unsigned long)target_p->tsinfo, parv[3], extarg);
161 <  }
154 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%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, CAP_TS6, NOCAPS,
160 <                  ":%s SVSMODE %s %lu %s", ID(source_p),
166 <                  ID(target_p), (unsigned long)target_p->tsinfo, parv[3]);
167 <    sendto_server(client_p, NOCAPS, CAP_TS6,
168 <                  ":%s SVSMODE %s %lu %s", source_p->name,
169 <                  target_p->name, (unsigned long)target_p->tsinfo, parv[3]);
170 <  }
158 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%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, 0xffffffff, modebuf);
167    }
168 +
169 +  return 0;
170   }
171  
172 < static struct Message svsmode_msgtab = {
172 > static struct Message svsmode_msgtab =
173 > {
174    "SVSMODE", 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
175 <  {m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore}
175 >  { m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore, m_ignore }
176   };
177  
178   static void
# Line 194 | Line 187 | module_exit(void)
187    mod_del_cmd(&svsmode_msgtab);
188   }
189  
190 < struct module module_entry = {
190 > struct module module_entry =
191 > {
192    .node    = { NULL, NULL, NULL },
193    .name    = NULL,
194    .version = "$Revision$",

Diff Legend

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