2001-06-10 Kevin L. Mitchell <klmitch@mit.edu>
+ * ircd/send.c: remove unused vsendcmdto_one(), consolidating it
+ into sendcmdto_one(); define new sendcmdto_prio_one(), which
+ places the message into the priority queue
+
+ * ircd/s_user.c (hunt_server_prio_cmd): definition of
+ hunt_server_prio_cmd(), which simply calls sendcmdto_prio_one()
+ instead of sendcmdto_one()
+
+ * ircd/m_settime.c: use sendcmdto_prio_one() and
+ hunt_server_prio_cmd() to send SETTIME
+
+ * ircd/m_server.c: use sendcmdto_prio_one() to send SETTIME
+
+ * include/send.h: removed declaration for unused vsendcmdto_one();
+ added a declaration for sendcmdto_prio_one()
+
+ * include/s_user.h: declare hunt_server_prio_cmd(), which calls
+ sendcmdto_prio_one()
+
* ircd/send.c (sendcmdto_flag_butone): oops; /wallops should be
put in the server's priority queue, too...
const char *tok, struct Client *one,
int MustBeOper, const char *pattern, int server,
int parc, char *parv[]);
+extern int hunt_server_prio_cmd(struct Client *from, const char *cmd,
+ const char *tok, struct Client *one,
+ int MustBeOper, const char *pattern,
+ int server, int parc, char *parv[]);
extern struct Client* next_client(struct Client* next, const char* ch);
extern char *umode_str(struct Client *cptr);
extern void send_umode(struct Client *cptr, struct Client *sptr, int old, int sendmask);
const char *tok, struct Client *to,
const char *pattern, ...);
-
-/* Same as above, except it takes a va_list */
-extern void vsendcmdto_one(struct Client *from, const char *cmd,
- const char *tok, struct Client *to,
- const char *pattern, va_list vl);
+/* Same as above, except it puts the message on the priority queue */
+extern void sendcmdto_prio_one(struct Client *from, const char *cmd,
+ const char *tok, struct Client *to,
+ const char *pattern, ...);
/* Send command to all servers except one */
extern void sendcmdto_serv_butone(struct Client *from, const char *cmd,
"timestamp-clock difference of %Td seconds! "
"Used SETTIME to correct this.",
timestamp - recv_time);
- sendcmdto_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me));
+ sendcmdto_prio_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(),
+ cli_name(&me));
}
return ret;
sendto_opmask_butone(0, SNO_OLDSNO, "Connected to a net with a "
"timestamp-clock difference of %Td seconds! Used "
"SETTIME to correct this.", timestamp - recv_time);
- sendcmdto_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me));
+ sendcmdto_prio_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(),
+ cli_name(&me));
}
return ret;
{
ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
parv[1] = tbuf;
- if (hunt_server_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc, parv) !=
- HUNTED_ISME)
+ if (hunt_server_prio_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc,
+ parv) != HUNTED_ISME)
return 0;
}
for (lp = cli_serv(&me)->down; lp; lp = lp->next)
if (cptr != lp->value.cptr && MsgQLength(&(cli_sendQ(lp->value.cptr))) < 8000)
- sendcmdto_one(sptr, CMD_SETTIME, lp->value.cptr, "%s", parv[1]);
+ sendcmdto_prio_one(sptr, CMD_SETTIME, lp->value.cptr, "%s", parv[1]);
}
else
{
ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
parv[1] = tbuf;
- if (hunt_server_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc, parv) !=
- HUNTED_ISME)
+ if (hunt_server_prio_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc,
+ parv) != HUNTED_ISME)
return 0;
}
return (HUNTED_PASS);
}
+int hunt_server_prio_cmd(struct Client *from, const char *cmd, const char *tok,
+ struct Client *one, int MustBeOper,
+ const char *pattern, int server, int parc,
+ char *parv[])
+{
+ struct Client *acptr;
+ char *to;
+
+ /* Assume it's me, if no server or an unregistered client */
+ if (parc <= server || EmptyString((to = parv[server])) || IsUnknown(from))
+ return (HUNTED_ISME);
+
+ /* Make sure it's a server */
+ if (MyUser(from)) {
+ /* Make sure it's a server */
+ if (!strchr(to, '*')) {
+ if (0 == (acptr = FindClient(to)))
+ return HUNTED_NOSUCH;
+
+ if (cli_user(acptr))
+ acptr = cli_user(acptr)->server;
+ } else if (!(acptr = find_match_server(to))) {
+ send_reply(from, ERR_NOSUCHSERVER, to);
+ return (HUNTED_NOSUCH);
+ }
+ } else if (!(acptr = FindNServer(to)))
+ return (HUNTED_NOSUCH); /* Server broke off in the meantime */
+
+ if (IsMe(acptr))
+ return (HUNTED_ISME);
+
+ if (MustBeOper && !IsPrivileged(from)) {
+ send_reply(from, ERR_NOPRIVILEGES);
+ return HUNTED_NOSUCH;
+ }
+
+ assert(!IsServer(from));
+
+ parv[server] = (char *) acptr; /* HACK! HACK! HACK! ARGH! */
+
+ sendcmdto_prio_one(from, cmd, tok, acptr, pattern, parv[1], parv[2], parv[3],
+ parv[4], parv[5], parv[6], parv[7], parv[8]);
+
+ return (HUNTED_PASS);
+}
+
/*
* 'do_nick_name' ensures that the given parameter (nick) is really a proper
* string for a nickname (note, the 'nick' may be modified in the process...)
void sendcmdto_one(struct Client *from, const char *cmd, const char *tok,
struct Client *to, const char *pattern, ...)
{
- va_list vl;
+ struct VarData vd;
+ struct MsgBuf *mb;
- va_start(vl, pattern);
- vsendcmdto_one(from, cmd, tok, to, pattern, vl);
- va_end(vl);
+ to = cli_from(to);
+
+ vd.vd_format = pattern; /* set up the struct VarData for %v */
+ va_start(vd.vd_args, pattern);
+
+ mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
+ &vd);
+
+ va_end(vd.vd_args);
+
+ send_buffer(to, mb, 0);
+
+ msgq_clean(mb);
}
-void vsendcmdto_one(struct Client *from, const char *cmd, const char *tok,
- struct Client *to, const char *pattern, va_list vl)
+/*
+ * Send a (prefixed) command to a single client in the priority queue;
+ * select which of <cmd> <tok> to use depending on if to is a server
+ *or not. <from> is the originator of the command.
+ */
+void sendcmdto_prio_one(struct Client *from, const char *cmd, const char *tok,
+ struct Client *to, const char *pattern, ...)
{
struct VarData vd;
struct MsgBuf *mb;
to = cli_from(to);
vd.vd_format = pattern; /* set up the struct VarData for %v */
- vd.vd_args = vl;
+ va_start(vd.vd_args, pattern);
mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
&vd);
- send_buffer(to, mb, 0);
+ va_end(vd.vd_args);
+
+ send_buffer(to, mb, 1);
msgq_clean(mb);
}