#include "s_debug.h"
#include "s_misc.h"
#include "s_user.h"
-#include "sprintf_irc.h"
#include "struct.h"
#include "sys.h"
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);
}
for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
if (one && lp->value.cptr == cli_from(one))
continue;
- send_buffer(lp->value.cptr, mb, 0);
+ send_buffer(lp->value.cptr, mb, 1);
}
msgq_clean(mb);
/* send buffer along */
sentalong_marker++;
for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) {
- if (cli_from(cptr) == one || IsServer(cptr) || IsMe(cptr) ||
- !match_it(cptr, to, who) || cli_fd(cli_from(cptr)) < 0 ||
+ if (!IsRegistered(cptr) || cli_from(cptr) == one || IsServer(cptr) ||
+ IsMe(cptr) || !match_it(cptr, to, who) || cli_fd(cli_from(cptr)) < 0 ||
sentalong[cli_fd(cli_from(cptr))] == sentalong_marker)
continue; /* skip it */
sentalong[cli_fd(cli_from(cptr))] = sentalong_marker;
va_end(vl);
}
+/*
+ * Send a server notice to all users subscribing to the indicated <mask>
+ * except for <one> - Ratelimited 1 / 30sec
+ */
+void sendto_opmask_butone_ratelimited(struct Client *one, unsigned int mask,
+ time_t *rate, const char *pattern, ...)
+{
+ va_list vl;
+
+ if ((CurrentTime - *rate) < 30)
+ return;
+ else
+ *rate = CurrentTime;
+
+ va_start(vl, pattern);
+ vsendto_opmask_butone(one, mask, pattern, vl);
+ va_end(vl);
+
+}
+
+
/*
* Same as above, except called with a variable argument list
*/