Tidy blank lines when outputting server info.

This commit is contained in:
nicm 2015-05-12 19:36:08 +00:00
parent ec34439f9c
commit 37ae8a9e0f

View File

@ -47,11 +47,11 @@ const struct cmd_entry cmd_server_info_entry = {
cmd_show_messages_exec cmd_show_messages_exec
}; };
void cmd_show_messages_server(struct cmd_q *); int cmd_show_messages_server(struct cmd_q *);
void cmd_show_messages_terminals(struct cmd_q *); int cmd_show_messages_terminals(struct cmd_q *, int);
void cmd_show_messages_jobs(struct cmd_q *); int cmd_show_messages_jobs(struct cmd_q *, int);
void int
cmd_show_messages_server(struct cmd_q *cmdq) cmd_show_messages_server(struct cmd_q *cmdq)
{ {
char *tim; char *tim;
@ -63,10 +63,12 @@ cmd_show_messages_server(struct cmd_q *cmdq)
cmdq_print(cmdq, "socket path %s", socket_path); cmdq_print(cmdq, "socket path %s", socket_path);
cmdq_print(cmdq, "debug level %d", debug_level); cmdq_print(cmdq, "debug level %d", debug_level);
cmdq_print(cmdq, "protocol version %d", PROTOCOL_VERSION); cmdq_print(cmdq, "protocol version %d", PROTOCOL_VERSION);
return (1);
} }
void int
cmd_show_messages_terminals(struct cmd_q *cmdq) cmd_show_messages_terminals(struct cmd_q *cmdq, int blank)
{ {
struct tty_term *term; struct tty_term *term;
const struct tty_term_code_entry *ent; const struct tty_term_code_entry *ent;
@ -76,8 +78,11 @@ cmd_show_messages_terminals(struct cmd_q *cmdq)
n = 0; n = 0;
LIST_FOREACH(term, &tty_terms, entry) { LIST_FOREACH(term, &tty_terms, entry) {
cmdq_print(cmdq, if (blank) {
"Terminal %u: %s [references=%u, flags=0x%x]:", 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, term->name, term->references, term->flags);
n++; n++;
for (i = 0; i < NTTYCODE; i++) { for (i = 0; i < NTTYCODE; i++) {
@ -106,21 +111,26 @@ cmd_show_messages_terminals(struct cmd_q *cmdq)
} }
} }
} }
return (n != 0);
} }
void int
cmd_show_messages_jobs(struct cmd_q *cmdq) cmd_show_messages_jobs(struct cmd_q *cmdq, 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) {
cmdq_print(cmdq, if (blank) {
"Job %u: %s [fd=%d, pid=%d, status=%d]", 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, job->cmd, job->fd, job->pid, job->status);
n++; n++;
} }
return (n != 0);
} }
enum cmd_retval enum cmd_retval
@ -130,23 +140,19 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq)
struct client *c; struct client *c;
struct message_entry *msg; struct message_entry *msg;
char *tim; char *tim;
int done; int done, blank;
done = 0; done = blank = 0;
if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) { if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) {
cmd_show_messages_server(cmdq); blank = cmd_show_messages_server(cmdq);
done = 1; done = 1;
} }
if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) { if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) {
if (done) blank = cmd_show_messages_terminals(cmdq, blank);
cmdq_print(cmdq, "%s", "");
cmd_show_messages_terminals(cmdq);
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) {
if (done) cmd_show_messages_jobs(cmdq, blank);
cmdq_print(cmdq, "%s", "");
cmd_show_messages_jobs(cmdq);
done = 1; done = 1;
} }
if (done) if (done)