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 1219 by michael, Sun Sep 18 09:02:38 2011 UTC vs.
ircd-hybrid/trunk/modules/m_svsmode.c (file contents), Revision 3300 by michael, Sat Apr 12 18:26:22 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 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"
31   #include "s_serv.h"
32   #include "send.h"
33   #include "channel_mode.h"
37 – #include "msg.h"
34   #include "parse.h"
35   #include "modules.h"
36   #include "irc_string.h"
37   #include "s_user.h"
38 + #include "conf.h"
39  
43 – static void ms_svsmode(struct Client *, struct Client *, int, char *[]);
40  
41 < struct Message svsmode_msgtab = {
46 <  "SVSMODE", 0, 0, 3, MAXPARA, 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)
41 > /*! \brief SVSMODE command handler
42   *
67 – * \param client_p Pointer to allocated Client struct with physical connection
68 – *                 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 arguement (services id)
53 > *      - parv[4] = optional argument (services id)
54   */
55 < static void
56 < ms_svsmode(struct Client *client_p, struct Client *source_p,
83 <           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, setflags = 0;
61 <  char *m = NULL, *modes = NULL, *extarg = NULL;
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) || (parc < 3))
65 <    return;
64 >  if (!HasFlag(source_p, FLAGS_SERVICE))
65 >    return 0;
66  
67    if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-')))
68    {
# Line 103 | 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 <  setflags = target_p->umodes;
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 123 | Line 96 | ms_svsmode(struct Client *client_p, stru
96          break;
97  
98        case 'd':
99 <        if (extarg && IsDigit(*extarg))
100 <          target_p->servicestamp = strtoul(extarg, NULL, 0);
99 >        if (!EmptyString(extarg))
100 >          strlcpy(target_p->svid, extarg, sizeof(target_p->svid));
101 >        break;
102 >
103 >      case 'x':
104 >        if (!EmptyString(extarg) && valid_hostname(extarg))
105 >          user_set_hostmask(target_p, extarg, what);
106          break;
107  
108        case 'o':
# Line 137 | Line 115 | ms_svsmode(struct Client *client_p, stru
115            {
116              dlink_node *dm = NULL;
117  
118 <            detach_conf(target_p, OPER_TYPE);
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 163 | Line 141 | ms_svsmode(struct Client *client_p, stru
141  
142          break;
143  
144 <      case ' ':
145 <      case '\n':
168 <      case '\r':
169 <      case '\t':
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:
149          if ((flag = user_modes[(unsigned char)*m]))
150 <          execute_callback(umode_cb, client_p, target_p, what, flag);
150 >        {
151 >          if (what == MODE_ADD)
152 >            AddUMode(target_p, flag);
153 >          else
154 >            DelUMode(target_p, flag);
155 >        }
156 >
157          break;
158      }
159    }
160  
161    if (extarg)
162 <  {
163 <    sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
164 <                  ":%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 <  }
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, NULL, CAP_TS6, NOCAPS,
168 <                  ":%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 <  }
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) && (setflags != target_p->umodes))
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, setflags, 0xffffffff, modebuf);
174 >    send_umode(target_p, target_p, setmodes, 0xffffffff, modebuf);
175    }
176 +
177 +  return 0;
178 + }
179 +
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 }
184 + };
185 +
186 + static void
187 + module_init(void)
188 + {
189 +  mod_add_cmd(&svsmode_msgtab);
190 + }
191 +
192 + static void
193 + module_exit(void)
194 + {
195 +  mod_del_cmd(&svsmode_msgtab);
196   }
197 +
198 + struct module module_entry =
199 + {
200 +  .node    = { NULL, NULL, NULL },
201 +  .name    = NULL,
202 +  .version = "$Revision$",
203 +  .handle  = NULL,
204 +  .modinit = module_init,
205 +  .modexit = module_exit,
206 +  .flags   = 0
207 + };

Comparing:
ircd-hybrid-8/modules/m_svsmode.c (property svn:eol-style), Revision 1219 by michael, Sun Sep 18 09:02:38 2011 UTC vs.
ircd-hybrid/trunk/modules/m_svsmode.c (property svn:eol-style), Revision 3300 by michael, Sat Apr 12 18:26:22 2014 UTC

# Line 0 | Line 1
1 + native

Diff Legend

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