| 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 client_p Pointer to allocated Client struct with physical connection |
| 44 |
– |
* 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 int |
| 56 |
< |
ms_svsmode(struct Client *client_p, struct Client *source_p, |
| 59 |
< |
int parc, char *parv[]) |
| 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 |
< |
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)) |
| 76 |
|
extarg = (parc > 3) ? parv[3] : NULL; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
< |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
| 79 |
> |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
| 80 |
|
return 0; |
| 81 |
|
|
| 82 |
|
if (ts && (ts != target_p->tsinfo)) |
| 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 |
|
{ |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
if (extarg) |
| 162 |
< |
{ |
| 163 |
< |
sendto_server(client_p, CAP_TS6, NOCAPS, |
| 164 |
< |
":%s SVSMODE %s %lu %s %s", ID(source_p), |
| 168 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes, extarg); |
| 169 |
< |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 170 |
< |
":%s SVSMODE %s %lu %s %s", source_p->name, |
| 171 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes, extarg); |
| 172 |
< |
} |
| 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), |
| 177 |
< |
ID(target_p), (unsigned long)target_p->tsinfo, modes); |
| 178 |
< |
sendto_server(client_p, NOCAPS, CAP_TS6, |
| 179 |
< |
":%s SVSMODE %s %lu %s", source_p->name, |
| 180 |
< |
target_p->name, (unsigned long)target_p->tsinfo, modes); |
| 181 |
< |
} |
| 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 |
|
} |