/* send the message to the link the target is attached to */
#define send_linebuf(a,b) _send_linebuf((a->from ? a->from : a) ,b)
+#define CLIENT_CAPS_ONLY(x) ((IsClient((x)) && (x)->localClient) ? (x)->localClient->caps : 0)
+
static void send_queued_write(rb_fde_t *F, void *data);
unsigned long current_serial = 0L;
}
/*
- * linebuf_put_msgvbuf
+ * linebuf_put_*
*
* inputs - msgbuf header, linebuf object, capability mask, pattern, arguments
* outputs - none
- * side effects - the linebuf object is cleared, then populated using rb_linebuf_putmsg().
+ * side effects - the linebuf object is cleared, then populated
*/
static void
-linebuf_put_msgvbuf(struct MsgBuf *msgbuf, buf_head_t *linebuf, unsigned int capmask, const char *pattern, va_list *va)
+linebuf_put_tags(buf_head_t *linebuf, const struct MsgBuf *msgbuf, const struct Client *target_p, rb_strf_t *message)
{
- char buf[BUFSIZE];
+ struct MsgBuf_str_data msgbuf_str_data = { .msgbuf = msgbuf, .caps = CLIENT_CAPS_ONLY(target_p) };
+ rb_strf_t strings = { .func = msgbuf_unparse_linebuf_tags, .func_args = &msgbuf_str_data, .length = TAGSLEN + 1, .next = message };
- rb_linebuf_newbuf(linebuf);
- msgbuf_unparse_prefix(buf, sizeof buf, msgbuf, capmask);
- rb_linebuf_putprefix(linebuf, pattern, va, buf);
+ message->length = DATALEN + 1;
+ rb_linebuf_put(linebuf, &strings);
+}
+
+static void
+linebuf_put_tagsf(buf_head_t *linebuf, const struct MsgBuf *msgbuf, const struct Client *target_p, const rb_strf_t *message, const char *format, ...)
+{
+ va_list va;
+ rb_strf_t strings = { .format = format, .format_args = &va, .next = message };
+
+ va_start(va, format);
+ linebuf_put_tags(linebuf, msgbuf, target_p, &strings);
+ va_end(va);
}
-/* linebuf_put_msgbuf
- *
- * inputs - msgbuf header, linebuf object, capability mask, pattern, arguments
- * outputs - none
- * side effects - the linebuf object is cleared, then populated using rb_linebuf_putmsg().
- */
static void
-linebuf_put_msgbuf(struct MsgBuf *msgbuf, buf_head_t *linebuf, unsigned int capmask, const char *pattern, ...)
+linebuf_put_msg(buf_head_t *linebuf, rb_strf_t *message)
+{
+ message->length = DATALEN + 1;
+ rb_linebuf_put(linebuf, message);
+}
+
+static void
+linebuf_put_msgf(buf_head_t *linebuf, const rb_strf_t *message, const char *format, ...)
{
va_list va;
+ rb_strf_t strings = { .format = format, .format_args = &va, .next = message };
- va_start(va, pattern);
- linebuf_put_msgvbuf(msgbuf, linebuf, capmask, pattern, &va);
+ va_start(va, format);
+ linebuf_put_msg(linebuf, &strings);
va_end(va);
}
-/* build_msgbuf_from
+/* build_msgbuf_tags
*
* inputs - msgbuf object, client the message is from
* outputs - none
* notes - to make this reentrant, find a solution for `buf` below
*/
static void
-build_msgbuf_from(struct MsgBuf *msgbuf, struct Client *from, const char *cmd)
+build_msgbuf_tags(struct MsgBuf *msgbuf, struct Client *from)
{
- static char buf[BUFSIZE];
hook_data hdata;
msgbuf_init(msgbuf);
- msgbuf->origin = buf;
- msgbuf->cmd = cmd;
-
- if (from != NULL && IsPerson(from))
- snprintf(buf, sizeof buf, "%s!%s@%s", from->name, from->username, from->host);
- else if (from != NULL)
- rb_strlcpy(buf, from->name, sizeof buf);
- else
- rb_strlcpy(buf, me.name, sizeof buf);
-
hdata.client = from;
hdata.arg1 = msgbuf;
sendto_one(struct Client *target_p, const char *pattern, ...)
{
va_list args;
+ struct MsgBuf msgbuf;
buf_head_t linebuf;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
/* send remote if to->from non NULL */
if(target_p->from != NULL)
rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, &me);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ linebuf_put_tags(&linebuf, &msgbuf, target_p, &strings);
va_end(args);
_send_linebuf(target_p, &linebuf);
{
struct Client *dest_p = target_p->from;
va_list args;
+ struct MsgBuf msgbuf;
buf_head_t linebuf;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
if(IsIOError(dest_p))
return;
return;
}
+ build_msgbuf_tags(&msgbuf, source_p);
+
rb_linebuf_newbuf(&linebuf);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args,
- ":%s %s %s ",
- get_id(source_p, target_p),
- command, get_id(target_p, target_p));
+ linebuf_put_tagsf(&linebuf, &msgbuf, target_p, &strings,
+ ":%s %s %s ", get_id(source_p, target_p),
+ command, get_id(target_p, target_p));
va_end(args);
_send_linebuf(dest_p, &linebuf);
void
sendto_one_notice(struct Client *target_p, const char *pattern, ...)
{
- struct Client *dest_p;
+ struct Client *dest_p = target_p->from;
va_list args;
+ struct MsgBuf msgbuf;
buf_head_t linebuf;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
char *to;
- /* send remote if to->from non NULL */
- if(target_p->from != NULL)
- dest_p = target_p->from;
- else
- dest_p = target_p;
-
if(IsIOError(dest_p))
return;
return;
}
+ build_msgbuf_tags(&msgbuf, &me);
+
rb_linebuf_newbuf(&linebuf);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args,
- ":%s NOTICE %s ",
- get_id(&me, target_p), *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
+ linebuf_put_tagsf(&linebuf, &msgbuf, target_p, &strings,
+ ":%s NOTICE %s ", get_id(&me, target_p),
+ *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
va_end(args);
_send_linebuf(dest_p, &linebuf);
void
sendto_one_numeric(struct Client *target_p, int numeric, const char *pattern, ...)
{
- struct Client *dest_p;
+ struct Client *dest_p = target_p->from;
va_list args;
+ struct MsgBuf msgbuf;
buf_head_t linebuf;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
char *to;
- /* send remote if to->from non NULL */
- if(target_p->from != NULL)
- dest_p = target_p->from;
- else
- dest_p = target_p;
-
if(IsIOError(dest_p))
return;
return;
}
+ build_msgbuf_tags(&msgbuf, &me);
+
rb_linebuf_newbuf(&linebuf);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args,
- ":%s %03d %s ",
- get_id(&me, target_p),
- numeric, *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
+ linebuf_put_tagsf(&linebuf, &msgbuf, target_p, &strings,
+ ":%s %03d %s ", get_id(&me, target_p), numeric,
+ *(to = get_id(target_p, target_p)) != '\0' ? to : "*");
va_end(args);
_send_linebuf(dest_p, &linebuf);
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
buf_head_t linebuf;
+ rb_strf_t strings = { .format = format, .format_args = &args, .next = NULL };
/* noone to send to.. */
if(rb_dlink_list_length(&serv_list) == 0)
rb_linebuf_newbuf(&linebuf);
va_start(args, format);
- rb_linebuf_putmsg(&linebuf, format, &args, NULL);
+ linebuf_put_msg(&linebuf, &strings);
va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head)
sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
struct Channel *chptr, const char *pattern, ...)
{
- char buf[BUFSIZE];
+ static char buf[BUFSIZE];
va_list args;
- buf_head_t rb_linebuf_local;
- buf_head_t rb_linebuf_id;
+ buf_head_t rb_linebuf_remote;
struct Client *target_p;
struct membership *msptr;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
- int current_capmask = 0;
struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = buf, .format_args = NULL, .next = NULL };
- rb_linebuf_newbuf(&rb_linebuf_local);
- rb_linebuf_newbuf(&rb_linebuf_id);
+ rb_linebuf_newbuf(&rb_linebuf_remote);
current_serial++;
- build_msgbuf_from(&msgbuf, source_p, NULL);
+ build_msgbuf_tags(&msgbuf, source_p);
va_start(args, pattern);
vsnprintf(buf, sizeof buf, pattern, args);
va_end(args);
- linebuf_put_msgbuf(&msgbuf, &rb_linebuf_local, NOCAPS, "%s", buf);
- rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
+ linebuf_put_msgf(&rb_linebuf_remote, NULL, ":%s %s", use_id(source_p), buf);
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
+ IsPerson(source_p) ? ":%1$s!%2$s@%3$s " : ":%1$s ",
+ source_p->name, source_p->username, source_p->host);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
{
if(target_p->from->serial != current_serial)
{
- send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
+ send_linebuf_remote(target_p, source_p, &rb_linebuf_remote);
target_p->from->serial = current_serial;
}
}
else
{
- if (target_p->localClient->caps != current_capmask)
- {
- /* reset the linebuf */
- rb_linebuf_donebuf(&rb_linebuf_local);
- rb_linebuf_newbuf(&rb_linebuf_local);
-
- /* render the new linebuf and attach it */
- linebuf_put_msgbuf(&msgbuf, &rb_linebuf_local, target_p->localClient->caps, "%s", buf);
- current_capmask = target_p->localClient->caps;
- }
-
- _send_linebuf(target_p, &rb_linebuf_local);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
}
{
target_p = one;
- if (target_p->localClient->caps != current_capmask)
- {
- /* reset the linebuf */
- rb_linebuf_donebuf(&rb_linebuf_local);
- rb_linebuf_newbuf(&rb_linebuf_local);
-
- /* render the new linebuf and attach it */
- linebuf_put_msgbuf(&msgbuf, &rb_linebuf_local, target_p->localClient->caps, "%s", buf);
- current_capmask = target_p->localClient->caps;
- }
-
- _send_linebuf(target_p, &rb_linebuf_local);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&rb_linebuf_local);
- rb_linebuf_donebuf(&rb_linebuf_id);
+ rb_linebuf_donebuf(&rb_linebuf_remote);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_channel_flags()
struct Channel *chptr, const char *command,
const char *text)
{
- buf_head_t rb_linebuf_local;
buf_head_t rb_linebuf_old;
buf_head_t rb_linebuf_new;
struct Client *target_p;
struct membership *msptr;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = text, .format_args = NULL, .next = NULL };
- rb_linebuf_newbuf(&rb_linebuf_local);
rb_linebuf_newbuf(&rb_linebuf_old);
rb_linebuf_newbuf(&rb_linebuf_new);
+ build_msgbuf_tags(&msgbuf, source_p);
+
current_serial++;
- if(IsServer(source_p))
- rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
- ":%s %s %s :%s",
- source_p->name, command, chptr->chname, text);
- else
- rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
- ":%s!%s@%s %s %s :%s",
+ if(IsServer(source_p)) {
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
+ ":%s %s %s :",
+ source_p->name, command, chptr->chname);
+ } else {
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
+ ":%s!%s@%s %s %s :",
source_p->name, source_p->username,
- source_p->host, command, chptr->chname, text);
+ source_p->host, command, chptr->chname);
+ }
- if (chptr->mode.mode & MODE_MODERATED)
- rb_linebuf_putmsg(&rb_linebuf_old, NULL, NULL,
- ":%s %s %s :%s",
+ if (chptr->mode.mode & MODE_MODERATED) {
+ linebuf_put_msgf(&rb_linebuf_old, &strings,
+ ":%s %s %s :",
use_id(source_p), command, chptr->chname, text);
- else
- rb_linebuf_putmsg(&rb_linebuf_old, NULL, NULL,
- ":%s NOTICE @%s :<%s:%s> %s",
+ } else {
+ linebuf_put_msgf(&rb_linebuf_old, &strings,
+ ":%s NOTICE @%s :<%s:%s> ",
use_id(source_p->servptr), chptr->chname,
- source_p->name, chptr->chname, text);
- rb_linebuf_putmsg(&rb_linebuf_new, NULL, NULL,
- ":%s %s =%s :%s",
- use_id(source_p), command, chptr->chname, text);
+ source_p->name, chptr->chname);
+ }
+ linebuf_put_msgf(&rb_linebuf_new, &strings,
+ ":%s %s =%s :",
+ use_id(source_p), command, chptr->chname);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
{
send_linebuf_remote(target_p, source_p, &rb_linebuf_old);
target_p->from->serial = current_serial;
}
+ } else {
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- else
- _send_linebuf(target_p, &rb_linebuf_local);
}
/* source client may not be on the channel, send echo separately */
{
target_p = one;
- _send_linebuf(target_p, &rb_linebuf_local);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&rb_linebuf_local);
rb_linebuf_donebuf(&rb_linebuf_old);
rb_linebuf_donebuf(&rb_linebuf_new);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_channel_local()
*
- * inputs - flags to send to, channel to send to, va_args
+ * inputs - source, flags to send to, channel to send to, va_args
* outputs - message to local channel members
* side effects -
*/
void
-sendto_channel_local(int type, struct Channel *chptr, const char *pattern, ...)
+sendto_channel_local(struct Client *source_p, int type, struct Channel *chptr, const char *pattern, ...)
{
va_list args;
- buf_head_t linebuf;
struct membership *msptr;
struct Client *target_p;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, source_p);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
else if(type && ((msptr->flags & type) == 0))
continue;
- _send_linebuf(target_p, &linebuf);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/*
* Shared implementation of sendto_channel_local_with_capability and sendto_channel_local_with_capability_butone
*/
static void
-_sendto_channel_local_with_capability_butone(struct Client *one, int type, int caps, int negcaps, struct Channel *chptr,
- const char *pattern, va_list * args)
+_sendto_channel_local_with_capability_butone(struct Client *source_p, struct Client *one, int type,
+ int caps, int negcaps, struct Channel *chptr, const char *pattern, va_list * args)
{
- buf_head_t linebuf;
struct membership *msptr;
struct Client *target_p;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
- rb_linebuf_putmsg(&linebuf, pattern, args, NULL);
+ build_msgbuf_tags(&msgbuf, source_p);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
{
if(type && ((msptr->flags & type) == 0))
continue;
- _send_linebuf(target_p, &linebuf);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_channel_local_with_capability()
*
- * inputs - flags to send to, caps, negate caps, channel to send to, va_args
+ * inputs - source, flags to send to, caps, negate caps, channel to send to, va_args
* outputs - message to local channel members
* side effects -
*/
void
-sendto_channel_local_with_capability(int type, int caps, int negcaps, struct Channel *chptr, const char *pattern, ...)
+sendto_channel_local_with_capability(struct Client *source_p, int type, int caps, int negcaps, struct Channel *chptr, const char *pattern, ...)
{
va_list args;
va_start(args, pattern);
- _sendto_channel_local_with_capability_butone(NULL, type, caps, negcaps, chptr, pattern, &args);
+ _sendto_channel_local_with_capability_butone(source_p, NULL, type, caps, negcaps, chptr, pattern, &args);
va_end(args);
}
/* sendto_channel_local_with_capability()
*
- * inputs - flags to send to, caps, negate caps, channel to send to, va_args
+ * inputs - source, flags to send to, caps, negate caps, channel to send to, va_args
* outputs - message to local channel members
* side effects -
*/
void
-sendto_channel_local_with_capability_butone(struct Client *one, int type, int caps, int negcaps, struct Channel *chptr,
- const char *pattern, ...)
+sendto_channel_local_with_capability_butone(struct Client *one, int type,
+ int caps, int negcaps, struct Channel *chptr, const char *pattern, ...)
{
va_list args;
va_start(args, pattern);
- _sendto_channel_local_with_capability_butone(one, type, caps, negcaps, chptr, pattern, &args);
+ _sendto_channel_local_with_capability_butone(one, one, type, caps, negcaps, chptr, pattern, &args);
va_end(args);
}
sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr, const char *pattern, ...)
{
va_list args;
- buf_head_t linebuf;
struct membership *msptr;
struct Client *target_p;
struct MsgBuf msgbuf;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
-
- build_msgbuf_from(&msgbuf, one, NULL);
+ build_msgbuf_tags(&msgbuf, one);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
continue;
/* attach the present linebuf to the target */
- _send_linebuf(target_p, &linebuf);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/*
* sendto_common_channels_local()
*
* inputs - pointer to client
- * - capability mask
- * - negated capability mask
+ * - capability mask
+ * - negated capability mask
* - pattern to send
* output - NONE
* side effects - Sends a message to all people on local server who are
struct Client *target_p;
struct membership *msptr;
struct membership *mscptr;
- buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
+
+ build_msgbuf_tags(&msgbuf, user);
- rb_linebuf_newbuf(&linebuf);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
va_end(args);
++current_serial;
continue;
target_p->serial = current_serial;
- send_linebuf(target_p, &linebuf);
+ send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
}
/* this can happen when the user isnt in any channels, but we still
* need to send them the data, ie a nick change
*/
- if(MyConnect(user) && (user->serial != current_serial))
- send_linebuf(user, &linebuf);
+ if(MyConnect(user) && (user->serial != current_serial)
+ && IsCapable(user, cap) && NotCapable(user, negcap)) {
+ send_linebuf(user, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(user)));
+ }
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/*
* sendto_common_channels_local_butone()
*
* inputs - pointer to client
- * - capability mask
- * - negated capability mask
+ * - capability mask
+ * - negated capability mask
* - pattern to send
* output - NONE
* side effects - Sends a message to all people on local server who are
struct Client *target_p;
struct membership *msptr;
struct membership *mscptr;
- buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, user);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
va_end(args);
++current_serial;
continue;
target_p->serial = current_serial;
- send_linebuf(target_p, &linebuf);
+ send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_match_butone()
struct Client *target_p;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
- buf_head_t rb_linebuf_local;
- buf_head_t rb_linebuf_id;
+ buf_head_t rb_linebuf_remote;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = buf, .format_args = NULL, .next = NULL };
- rb_linebuf_newbuf(&rb_linebuf_local);
- rb_linebuf_newbuf(&rb_linebuf_id);
+ rb_linebuf_newbuf(&rb_linebuf_remote);
+
+ build_msgbuf_tags(&msgbuf, source_p);
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
- if(IsServer(source_p))
- rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
- ":%s %s", source_p->name, buf);
- else
- rb_linebuf_putmsg(&rb_linebuf_local, NULL, NULL,
- ":%s!%s@%s %s",
- source_p->name, source_p->username,
- source_p->host, buf);
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
+ IsServer(source_p) ? ":%s " : ":%s!%s@%s ",
+ source_p->name, source_p->username, source_p->host);
- rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s %s", use_id(source_p), buf);
+ linebuf_put_msgf(&rb_linebuf_remote, &strings, ":%s ", use_id(source_p));
if(what == MATCH_HOST)
{
target_p = ptr->data;
if(match(mask, target_p->host))
- _send_linebuf(target_p, &rb_linebuf_local);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
}
/* what = MATCH_SERVER, if it doesnt match us, just send remote */
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head)
{
target_p = ptr->data;
- _send_linebuf(target_p, &rb_linebuf_local);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
}
if(target_p == one)
continue;
- send_linebuf_remote(target_p, source_p, &rb_linebuf_id);
+ send_linebuf_remote(target_p, source_p, &rb_linebuf_remote);
}
- rb_linebuf_donebuf(&rb_linebuf_local);
- rb_linebuf_donebuf(&rb_linebuf_id);
+ msgbuf_cache_free(&msgbuf_cache);
+ rb_linebuf_donebuf(&rb_linebuf_remote);
}
/* sendto_match_servs()
rb_dlink_node *ptr;
struct Client *target_p;
buf_head_t rb_linebuf_id;
+ rb_strf_t strings = { .format = buf, .format_args = NULL, .next = NULL };
if(EmptyString(mask))
return;
vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
- rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL,
- ":%s %s", use_id(source_p), buf);
+ linebuf_put_msgf(&rb_linebuf_id, &strings, ":%s ", use_id(source_p));
current_serial++;
va_list args;
rb_dlink_node *ptr;
struct Client *target_p;
- buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, &me);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
va_end(args);
RB_DLINK_FOREACH(ptr, lclient_list.head)
if(IsIOError(target_p) || !IsCapable(target_p, cap))
continue;
- send_linebuf(target_p, &linebuf);
+ send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_monitor()
* side effects -
*/
void
-sendto_monitor(struct monitor *monptr, const char *pattern, ...)
+sendto_monitor(struct Client *source_p, struct monitor *monptr, const char *pattern, ...)
{
va_list args;
- buf_head_t linebuf;
struct Client *target_p;
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, source_p);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, NULL);
+ msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings);
va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head)
if(IsIOError(target_p))
continue;
- _send_linebuf(target_p, &linebuf);
+ _send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p)));
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* _sendto_anywhere()
const char *pattern, va_list *args)
{
buf_head_t linebuf;
+ rb_strf_t strings = { .format = pattern, .format_args = args, .next = NULL };
rb_linebuf_newbuf(&linebuf);
- if(MyClient(dest_p))
- {
- if(IsServer(source_p))
- rb_linebuf_putmsg(&linebuf, pattern, args, ":%s %s %s ",
+ if (MyClient(dest_p)) {
+ if (IsServer(source_p)) {
+ linebuf_put_msgf(&linebuf, &strings, ":%s %s %s ",
source_p->name, command,
target_p->name);
- else
- {
+ } else {
struct MsgBuf msgbuf;
- build_msgbuf_from(&msgbuf, source_p, command);
- msgbuf.target = target_p->name;
+ build_msgbuf_tags(&msgbuf, source_p);
- linebuf_put_msgvbuf(&msgbuf, &linebuf, dest_p->localClient->caps, pattern, args);
+ linebuf_put_tagsf(&linebuf, &msgbuf, dest_p, &strings,
+ IsPerson(source_p) ? ":%1$s!%4$s@%5$s %2$s %3$s " : ":%1$s %2$s %3$s ",
+ source_p->name, command, target_p->name,
+ source_p->username, source_p->host);
}
- }
- else
- rb_linebuf_putmsg(&linebuf, pattern, args, ":%s %s %s ",
+
+ _send_linebuf(dest_p, &linebuf);
+ } else {
+ linebuf_put_msgf(&linebuf, &strings, ":%s %s %s ",
get_id(source_p, target_p), command,
get_id(target_p, target_p));
- if(MyClient(dest_p))
- _send_linebuf(dest_p, &linebuf);
- else
send_linebuf_remote(dest_p, source_p, &linebuf);
+ }
rb_linebuf_donebuf(&linebuf);
}
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
va_list args;
- buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, &me);
+
+ /* rather a lot of copying around, oh well -- jilles */
+ va_start(args, pattern);
+ vsnprintf(buf, sizeof(buf), pattern, args);
+ va_end(args);
+
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, NULL,
+ ":%s NOTICE * :*** Notice -- %s", me.name, buf);
/* Be very sure not to do things like "Trying to send to myself"
* L_NETWIDE, otherwise infinite recursion may result! -- jilles */
if (level & L_NETWIDE && ConfigFileEntry.global_snotices)
{
- /* rather a lot of copying around, oh well -- jilles */
- va_start(args, pattern);
- vsnprintf(buf, sizeof(buf), pattern, args);
- va_end(args);
- rb_linebuf_putmsg(&linebuf, pattern, NULL,
- ":%s NOTICE * :*** Notice -- %s", me.name, buf);
snobuf = construct_snobuf(flags);
if (snobuf[1] != '\0')
sendto_server(NULL, NULL, CAP_ENCAP|CAP_TS6, NOCAPS,
}
else if (remote_rehash_oper_p != NULL)
{
- /* rather a lot of copying around, oh well -- jilles */
- va_start(args, pattern);
- vsnprintf(buf, sizeof(buf), pattern, args);
- va_end(args);
- rb_linebuf_putmsg(&linebuf, pattern, NULL,
- ":%s NOTICE * :*** Notice -- %s", me.name, buf);
sendto_one_notice(remote_rehash_oper_p, ":*** Notice -- %s", buf);
}
- else
- {
- va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args,
- ":%s NOTICE * :*** Notice -- ", me.name);
- va_end(args);
- }
level &= ~L_NETWIDE;
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
((level == L_OPER) && IsOperAdmin(client_p)))
continue;
- if(client_p->snomask & flags)
- _send_linebuf(client_p, &linebuf);
+ if (client_p->snomask & flags) {
+ _send_linebuf(client_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(client_p)));
+ }
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* sendto_realops_snomask_from()
*
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
va_list args;
- buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, &me);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args,
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
":%s NOTICE * :*** Notice -- ", source_p->name);
va_end(args);
((level == L_OPER) && IsOperAdmin(client_p)))
continue;
- if(client_p->snomask & flags)
- _send_linebuf(client_p, &linebuf);
+ if (client_p->snomask & flags) {
+ _send_linebuf(client_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(client_p)));
+ }
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/*
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
va_list args;
- buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ struct MsgBuf_cache msgbuf_cache;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
- rb_linebuf_newbuf(&linebuf);
+ build_msgbuf_tags(&msgbuf, source_p);
va_start(args, pattern);
-
- if(IsPerson(source_p))
- rb_linebuf_putmsg(&linebuf, pattern, &args,
+ if (IsPerson(source_p)) {
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
":%s!%s@%s WALLOPS :", source_p->name,
source_p->username, source_p->host);
- else
- rb_linebuf_putmsg(&linebuf, pattern, &args, ":%s WALLOPS :", source_p->name);
-
+ } else {
+ msgbuf_cache_initf(&msgbuf_cache, &msgbuf, &strings,
+ ":%s WALLOPS :", source_p->name);
+ }
va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, IsPerson(source_p) && flags == UMODE_WALLOP ? lclient_list.head : local_oper_list.head)
{
client_p = ptr->data;
- if(client_p->umodes & flags)
- _send_linebuf(client_p, &linebuf);
+ if (client_p->umodes & flags) {
+ _send_linebuf(client_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(client_p)));
+ }
}
- rb_linebuf_donebuf(&linebuf);
+ msgbuf_cache_free(&msgbuf_cache);
}
/* kill_client()
{
va_list args;
buf_head_t linebuf;
+ struct MsgBuf msgbuf;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
+
+ build_msgbuf_tags(&msgbuf, &me);
rb_linebuf_newbuf(&linebuf);
va_start(args, pattern);
- rb_linebuf_putmsg(&linebuf, pattern, &args, ":%s KILL %s :",
- get_id(&me, target_p), get_id(diedie, target_p));
+ linebuf_put_tagsf(&linebuf, &msgbuf, target_p, &strings,
+ ":%s KILL %s :", get_id(&me, target_p), get_id(diedie, target_p));
va_end(args);
send_linebuf(target_p, &linebuf);
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
buf_head_t rb_linebuf_id;
+ rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL };
rb_linebuf_newbuf(&rb_linebuf_id);
va_start(args, pattern);
- vsnprintf(buf, sizeof(buf), pattern, args);
- va_end(args);
-
- rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s KILL %s :%s",
+ linebuf_put_msgf(&rb_linebuf_id, &strings, ":%s KILL %s :%s",
use_id(&me), use_id(target_p), buf);
+ va_end(args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head)
{