version 1.22, 2016/10/14 22:14:22 |
version 1.23, 2016/10/16 19:04:05 |
|
|
* Show client message log. |
* Show client message log. |
*/ |
*/ |
|
|
static enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_q *); |
static enum cmd_retval cmd_show_messages_exec(struct cmd *, |
|
struct cmdq_item *); |
|
|
const struct cmd_entry cmd_show_messages_entry = { |
const struct cmd_entry cmd_show_messages_entry = { |
.name = "show-messages", |
.name = "show-messages", |
|
|
.exec = cmd_show_messages_exec |
.exec = cmd_show_messages_exec |
}; |
}; |
|
|
static int cmd_show_messages_terminals(struct cmd_q *, int); |
static int cmd_show_messages_terminals(struct cmdq_item *, int); |
static int cmd_show_messages_jobs(struct cmd_q *, int); |
static int cmd_show_messages_jobs(struct cmdq_item *, int); |
|
|
static int |
static int |
cmd_show_messages_terminals(struct cmd_q *cmdq, int blank) |
cmd_show_messages_terminals(struct cmdq_item *item, int blank) |
{ |
{ |
struct tty_term *term; |
struct tty_term *term; |
u_int i, n; |
u_int i, n; |
|
|
n = 0; |
n = 0; |
LIST_FOREACH(term, &tty_terms, entry) { |
LIST_FOREACH(term, &tty_terms, entry) { |
if (blank) { |
if (blank) { |
cmdq_print(cmdq, "%s", ""); |
cmdq_print(item, "%s", ""); |
blank = 0; |
blank = 0; |
} |
} |
cmdq_print(cmdq, "Terminal %u: %s [references=%u, flags=0x%x]:", |
cmdq_print(item, "Terminal %u: %s [references=%u, flags=0x%x]:", |
n, term->name, term->references, term->flags); |
n, term->name, term->references, term->flags); |
n++; |
n++; |
for (i = 0; i < tty_term_ncodes(); i++) |
for (i = 0; i < tty_term_ncodes(); i++) |
cmdq_print(cmdq, "%s", tty_term_describe(term, i)); |
cmdq_print(item, "%s", tty_term_describe(term, i)); |
} |
} |
return (n != 0); |
return (n != 0); |
} |
} |
|
|
static int |
static int |
cmd_show_messages_jobs(struct cmd_q *cmdq, int blank) |
cmd_show_messages_jobs(struct cmdq_item *item, int blank) |
{ |
{ |
struct job *job; |
struct job *job; |
u_int n; |
u_int n; |
|
|
n = 0; |
n = 0; |
LIST_FOREACH(job, &all_jobs, lentry) { |
LIST_FOREACH(job, &all_jobs, lentry) { |
if (blank) { |
if (blank) { |
cmdq_print(cmdq, "%s", ""); |
cmdq_print(item, "%s", ""); |
blank = 0; |
blank = 0; |
} |
} |
cmdq_print(cmdq, "Job %u: %s [fd=%d, pid=%d, status=%d]", |
cmdq_print(item, "Job %u: %s [fd=%d, pid=%d, status=%d]", |
n, job->cmd, job->fd, job->pid, job->status); |
n, job->cmd, job->fd, job->pid, job->status); |
n++; |
n++; |
} |
} |
|
|
} |
} |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_show_messages_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct client *c = cmdq->state.c; |
struct client *c = item->state.c; |
struct message_entry *msg; |
struct message_entry *msg; |
char *tim; |
char *tim; |
int done, blank; |
int done, blank; |
|
|
done = blank = 0; |
done = blank = 0; |
if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) { |
if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) { |
blank = cmd_show_messages_terminals(cmdq, blank); |
blank = cmd_show_messages_terminals(item, blank); |
done = 1; |
done = 1; |
} |
} |
if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) { |
if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) { |
cmd_show_messages_jobs(cmdq, blank); |
cmd_show_messages_jobs(item, blank); |
done = 1; |
done = 1; |
} |
} |
if (done) |
if (done) |
|
|
tim = ctime(&msg->msg_time); |
tim = ctime(&msg->msg_time); |
*strchr(tim, '\n') = '\0'; |
*strchr(tim, '\n') = '\0'; |
|
|
cmdq_print(cmdq, "%s %s", tim, msg->msg); |
cmdq_print(item, "%s %s", tim, msg->msg); |
} |
} |
|
|
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |