diff options
author | Thomas Adam <thomas@xteddy.org> | 2015-05-13 09:44:11 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2015-05-13 09:44:11 +0100 |
commit | 00471dc78358bde092df65de5e2c375bf9be7437 (patch) | |
tree | 4db96614bbc7e70dcdeaa307a3280103beee2f9e /cmd-show-messages.c | |
parent | 4165ed96f8f0c494c7bd4f793176e508b6b6581d (diff) | |
parent | 3f4ee98162cd5bb7000f93fec0e631e123b1281d (diff) | |
download | rtmux-00471dc78358bde092df65de5e2c375bf9be7437.tar.gz rtmux-00471dc78358bde092df65de5e2c375bf9be7437.tar.bz2 rtmux-00471dc78358bde092df65de5e2c375bf9be7437.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-show-messages.c')
-rw-r--r-- | cmd-show-messages.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/cmd-show-messages.c b/cmd-show-messages.c index ccc11c92..681ff261 100644 --- a/cmd-show-messages.c +++ b/cmd-show-messages.c @@ -46,11 +46,11 @@ const struct cmd_entry cmd_server_info_entry = { cmd_show_messages_exec }; -void cmd_show_messages_server(struct cmd_q *); -void cmd_show_messages_terminals(struct cmd_q *); -void cmd_show_messages_jobs(struct cmd_q *); +int cmd_show_messages_server(struct cmd_q *); +int cmd_show_messages_terminals(struct cmd_q *, int); +int cmd_show_messages_jobs(struct cmd_q *, int); -void +int cmd_show_messages_server(struct cmd_q *cmdq) { char *tim; @@ -62,10 +62,12 @@ cmd_show_messages_server(struct cmd_q *cmdq) cmdq_print(cmdq, "socket path %s", socket_path); cmdq_print(cmdq, "debug level %d", debug_level); cmdq_print(cmdq, "protocol version %d", PROTOCOL_VERSION); + + return (1); } -void -cmd_show_messages_terminals(struct cmd_q *cmdq) +int +cmd_show_messages_terminals(struct cmd_q *cmdq, int blank) { struct tty_term *term; const struct tty_term_code_entry *ent; @@ -75,8 +77,11 @@ cmd_show_messages_terminals(struct cmd_q *cmdq) n = 0; LIST_FOREACH(term, &tty_terms, entry) { - cmdq_print(cmdq, - "Terminal %u: %s [references=%u, flags=0x%x]:", + if (blank) { + cmdq_print(cmdq, "%s", ""); + blank = 0; + } + cmdq_print(cmdq, "Terminal %u: %s [references=%u, flags=0x%x]:", n, term->name, term->references, term->flags); n++; for (i = 0; i < NTTYCODE; i++) { @@ -105,21 +110,26 @@ cmd_show_messages_terminals(struct cmd_q *cmdq) } } } + return (n != 0); } -void -cmd_show_messages_jobs(struct cmd_q *cmdq) +int +cmd_show_messages_jobs(struct cmd_q *cmdq, int blank) { struct job *job; u_int n; n = 0; LIST_FOREACH(job, &all_jobs, lentry) { - cmdq_print(cmdq, - "Job %u: %s [fd=%d, pid=%d, status=%d]", + if (blank) { + cmdq_print(cmdq, "%s", ""); + blank = 0; + } + cmdq_print(cmdq, "Job %u: %s [fd=%d, pid=%d, status=%d]", n, job->cmd, job->fd, job->pid, job->status); n++; } + return (n != 0); } enum cmd_retval @@ -129,23 +139,19 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq) struct client *c; struct message_entry *msg; char *tim; - int done; + int done, blank; - done = 0; + done = blank = 0; if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) { - cmd_show_messages_server(cmdq); + blank = cmd_show_messages_server(cmdq); done = 1; } if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) { - if (done) - cmdq_print(cmdq, "%s", ""); - cmd_show_messages_terminals(cmdq); + blank = cmd_show_messages_terminals(cmdq, blank); done = 1; } if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) { - if (done) - cmdq_print(cmdq, "%s", ""); - cmd_show_messages_jobs(cmdq); + cmd_show_messages_jobs(cmdq, blank); done = 1; } if (done) |