| 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 |
|
|
| 28 |
|
#include "stdinc.h" |
| 29 |
|
#include "client.h" |
| 30 |
|
#include "ircd.h" |
| 31 |
< |
#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" |
| 39 |
|
|
| 40 |
|
|
| 41 |
< |
/*! \brief SVSMODE command handler (called by services) |
| 41 |
> |
/*! \brief SVSMODE command handler |
| 42 |
|
* |
| 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. |
| 48 |
|
* \note Valid arguments for this command are: |
| 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) |
| 51 |
> |
* - parv[2] = TS |
| 52 |
> |
* - parv[3] = mode |
| 53 |
> |
* - parv[4] = optional argument (services id, vhost) |
| 54 |
|
*/ |
| 55 |
|
static int |
| 56 |
|
ms_svsmode(struct Client *source_p, int parc, char *parv[]) |
| 58 |
|
struct Client *target_p = NULL; |
| 59 |
|
int what = MODE_ADD; |
| 60 |
|
unsigned int flag = 0, setmodes = 0; |
| 61 |
< |
const 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 0; |
| 66 |
|
|
| 67 |
< |
if ((parc >= 4) && ((*parv[3] == '+') || (*parv[3] == '-'))) |
| 68 |
< |
{ |
| 69 |
< |
ts = atol(parv[2]); |
| 70 |
< |
modes = parv[3]; |
| 71 |
< |
extarg = (parc > 4) ? parv[4] : NULL; |
| 72 |
< |
} |
| 73 |
< |
else |
| 74 |
< |
{ |
| 75 |
< |
modes = parv[2]; |
| 76 |
< |
extarg = (parc > 3) ? parv[3] : NULL; |
| 77 |
< |
} |
| 67 |
> |
ts = atol(parv[2]); |
| 68 |
> |
modes = parv[3]; |
| 69 |
> |
extarg = (parc > 4) ? parv[4] : NULL; |
| 70 |
|
|
| 71 |
|
if ((target_p = find_person(source_p, parv[1])) == NULL) |
| 72 |
|
return 0; |
| 76 |
|
|
| 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 |
|
{ |
| 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 |
|
{ |
| 109 |
|
|
| 110 |
|
detach_conf(target_p, CONF_OPER); |
| 111 |
|
ClrOFlag(target_p); |
| 112 |
< |
DelUMode(target_p, ConfigFileEntry.oper_only_umodes); |
| 112 |
> |
DelUMode(target_p, ConfigGeneral.oper_only_umodes); |
| 113 |
|
|
| 114 |
|
if ((dm = dlinkFindDelete(&oper_list, target_p))) |
| 115 |
|
free_dlink_node(dm); |
| 152 |
|
|
| 153 |
|
if (extarg) |
| 154 |
|
sendto_server(source_p, NOCAPS, NOCAPS, ":%s SVSMODE %s %lu %s %s", |
| 155 |
< |
ID(source_p), |
| 156 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg); |
| 155 |
> |
source_p->id, |
| 156 |
> |
target_p->id, (unsigned long)target_p->tsinfo, modes, extarg); |
| 157 |
|
else |
| 158 |
|
sendto_server(source_p, NOCAPS, NOCAPS, ":%s SVSMODE %s %lu %s", |
| 159 |
< |
ID(source_p), |
| 160 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes); |
| 159 |
> |
source_p->id, |
| 160 |
> |
target_p->id, (unsigned long)target_p->tsinfo, modes); |
| 161 |
|
|
| 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, setmodes, 0xffffffff, modebuf); |
| 166 |
> |
send_umode(target_p, target_p, setmodes, modebuf); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
return 0; |
| 171 |
|
|
| 172 |
|
static struct Message svsmode_msgtab = |
| 173 |
|
{ |
| 174 |
< |
"SVSMODE", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
| 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 |
|
|