mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Break the message storage function into its own function, useful for
debugging.
This commit is contained in:
@ -1624,3 +1624,34 @@ server_client_push_stderr(struct client *c)
|
||||
log_debug("%s: client %p, queued", __func__, c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add to client message log. */
|
||||
void
|
||||
server_client_add_message(struct client *c, const char *fmt, ...)
|
||||
{
|
||||
struct message_entry *msg, *msg1;
|
||||
char *s;
|
||||
va_list ap;
|
||||
u_int limit;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&s, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
log_debug("%s: message %s", c->tty.path, s);
|
||||
|
||||
msg = xcalloc(1, sizeof *msg);
|
||||
msg->msg_time = time(NULL);
|
||||
msg->msg_num = c->message_next++;
|
||||
msg->msg = s;
|
||||
TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
|
||||
|
||||
limit = options_get_number(global_options, "message-limit");
|
||||
TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
|
||||
if (msg->msg_num + limit >= c->message_next)
|
||||
break;
|
||||
free(msg->msg);
|
||||
TAILQ_REMOVE(&c->message_log, msg, entry);
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user